GNU bug report logs - #43920
[SHEPHERD PATCH] shepherd: Move log file to XDG_CACHE_DIR.

Previous Next

Package: guix-patches;

Reported by: Efraim Flashner <efraim <at> flashner.co.il>

Date: Sun, 11 Oct 2020 09:22:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43920 in the body.
You can then email your comments to 43920 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#43920; Package guix-patches. (Sun, 11 Oct 2020 09:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Efraim Flashner <efraim <at> flashner.co.il>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 11 Oct 2020 09:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: guix-patches <at> gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [SHEPHERD PATCH] shepherd: Move log file to XDG_CACHE_DIR.
Date: Sun, 11 Oct 2020 12:20:17 +0300
* modules/shepherd/support.scm (%user-log-dir): New variable.
(user-default-log-file): Use it.
* doc/shepherd.texi: (Invoking shepherd): Adjust listed default log
file.
* tests/basic.sh: Adjust for separate log directory.
---
 doc/shepherd.texi            |  2 +-
 modules/shepherd/support.scm | 10 ++++++++--
 tests/basic.sh               |  4 ++++
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index 696477e..0c3901e 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -417,7 +417,7 @@ permissions are not as expected.
 Log output into @var{file}.
 
 For unprivileged users, the default log file is
-@file{$XDG_CONFIG_HOME/shepherd/shepherd.log}.
+@file{$XDG_CACHE_DIR/shepherd/shepherd.log}.
 
 @cindex syslog
 When running as root, the default behavior is to connect to
diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm
index cdb7b35..008b280 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -271,6 +271,12 @@ There is NO WARRANTY, to the extent permitted by law.")))
                      (string-append user-homedir "/.config"))
                  "/shepherd"))
 
+(define %user-log-dir
+  ;; Default log directory if shepherd is run as a normal user.
+  (string-append (or (getenv "XDG_CACHE_DIR")
+                     (string-append user-homedir "/.cache"))
+                 "/shepherd"))
+
 (define %user-runtime-dir
   ;; Default runtime directory if shepherd is run as a normal user.
   (string-append (or (getenv "XDG_RUNTIME_DIR")
@@ -302,8 +308,8 @@ TARGET should be a string representing a filepath + name."
 ;; Logging.
 (define (user-default-log-file)
   "Return the file name of the user's default log file."
-  (mkdir-p %user-config-dir #o700)
-  (string-append %user-config-dir "/shepherd.log"))
+  (mkdir-p %user-log-dir #o700)
+  (string-append %user-log-dir "/shepherd.log"))
 
 (define default-logfile-date-format
   ;; 'strftime' format string to prefix each entry in the log.
diff --git a/tests/basic.sh b/tests/basic.sh
index a6148fc..145c0d3 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -24,6 +24,7 @@ herd --version
 socket="t-socket-$$"
 conf="t-conf-$$"
 confdir="t-confdir-$$"
+cachedir="t-cachedir-$$"
 log="t-log-$$"
 stamp="t-stamp-$$"
 pid="t-pid-$$"
@@ -259,7 +260,9 @@ test -f "$log"
 
 # Set XDG_CONFIG_HOME for configuration files.
 export XDG_CONFIG_HOME=$confdir
+export XDG_CACHE_DIR=$cachedir
 mkdir -p $confdir/shepherd
+mkdir -p $cachedir/shepherd
 mv $conf $confdir/shepherd/init.scm
 rm -f "$pid" "$socket"
 shepherd -I -s "$socket" --pid="$pid" &
@@ -281,3 +284,4 @@ $herd stop root
 ! kill -0 $shepherd_pid
 
 rm -rf $confdir
+rm -rf $cachedir
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#43920; Package guix-patches. (Thu, 22 Oct 2020 14:25:02 GMT) Full text and rfc822 format available.

Message #8 received at 43920 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 43920 <at> debbugs.gnu.org
Subject: Re: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to
 XDG_CACHE_DIR.
Date: Thu, 22 Oct 2020 16:23:57 +0200
Hi,

Efraim Flashner <efraim <at> flashner.co.il> skribis:

> * modules/shepherd/support.scm (%user-log-dir): New variable.
> (user-default-log-file): Use it.
> * doc/shepherd.texi: (Invoking shepherd): Adjust listed default log
> file.
> * tests/basic.sh: Adjust for separate log directory.

[...]

>  For unprivileged users, the default log file is
> -@file{$XDG_CONFIG_HOME/shepherd/shepherd.log}.
> +@file{$XDG_CACHE_DIR/shepherd/shepherd.log}.

The previous location wasn’t perfect, but the proposed one isn’t great
either: one can generally assume “rm -rf ~/.cache” won’t lose anything
that cannot be reconstructed, and the log is something that cannot be
reconstructed.

Do the XDG spec have something else that might be more appropriate?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#43920; Package guix-patches. (Fri, 23 Oct 2020 22:18:02 GMT) Full text and rfc822 format available.

Message #11 received at 43920 <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: ludo <at> gnu.org
Cc: 43920 <at> debbugs.gnu.org
Subject: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to XDG_CACHE_DIR.
Date: Sat, 24 Oct 2020 00:17:22 +0200
> The previous location wasn’t perfect, but the proposed one isn’t
> great
> either: one can generally assume “rm -rf ~/.cache” won’t lose
> anything
> that cannot be reconstructed, and the log is something that cannot be
> reconstructed.
That is actually not part of the XDG specification – it merely states,
that non-essential files be put there.  Whether or not one considers
the shepherd log essential is debatable.

You could alternatively put it under $XDG_DATA_HOME.  Some projects
like Xorg seem to do that.  Of course, there always remains the option
of having yet another environment variable or command line parameter
for the placement of the log file.

Regards, Leo





Information forwarded to guix-patches <at> gnu.org:
bug#43920; Package guix-patches. (Sat, 24 Oct 2020 16:16:01 GMT) Full text and rfc822 format available.

Message #14 received at 43920 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>
Cc: "Jan \(janneke\) Nieuwenhuizen" <janneke <at> gnu.org>, 43920 <at> debbugs.gnu.org,
 Efraim Flashner <efraim <at> flashner.co.il>
Subject: Re: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to
 XDG_CACHE_DIR.
Date: Sat, 24 Oct 2020 18:15:33 +0200
Hi,

Leo Prikler <leo.prikler <at> student.tugraz.at> skribis:

>> The previous location wasn’t perfect, but the proposed one isn’t
>> great
>> either: one can generally assume “rm -rf ~/.cache” won’t lose
>> anything
>> that cannot be reconstructed, and the log is something that cannot be
>> reconstructed.
> That is actually not part of the XDG specification – it merely states,
> that non-essential files be put there.  Whether or not one considers
> the shepherd log essential is debatable.

Right, that’s my interpretation of what “cache” means.

> You could alternatively put it under $XDG_DATA_HOME.  Some projects
> like Xorg seem to do that.  Of course, there always remains the option
> of having yet another environment variable or command line parameter
> for the placement of the log file.

Yup, XDG_DATA_HOME would work for me; it seems to be rather in line with
what the XDG states and what Xorg does, as you note.

  https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

WDYT, Efraim & Janneke?

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#43920; Package guix-patches. (Sat, 24 Oct 2020 16:53:01 GMT) Full text and rfc822 format available.

Message #17 received at 43920 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>,
 Leo Prikler <leo.prikler <at> student.tugraz.at>
Cc: 43920 <at> debbugs.gnu.org, "Jan \(janneke\) Nieuwenhuizen" <janneke <at> gnu.org>
Subject: Re: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to
 XDG_CACHE_DIR.
Date: Sat, 24 Oct 2020 16:51:20 +0000

On October 24, 2020 4:15:33 PM UTC, "Ludovic Courtès" <ludo <at> gnu.org> wrote:
>Hi,
>
>Leo Prikler <leo.prikler <at> student.tugraz.at> skribis:
>
>>> The previous location wasn’t perfect, but the proposed one isn’t
>>> great
>>> either: one can generally assume “rm -rf ~/.cache” won’t lose
>>> anything
>>> that cannot be reconstructed, and the log is something that cannot be
>>> reconstructed.
>> That is actually not part of the XDG specification – it merely states,
>> that non-essential files be put there.  Whether or not one considers
>> the shepherd log essential is debatable.
>
>Right, that’s my interpretation of what “cache” means.
>

I felt like it belongs in cache much more than in a config dir.

>> You could alternatively put it under $XDG_DATA_HOME.  Some projects
>> like Xorg seem to do that.  Of course, there always remains the option
>> of having yet another environment variable or command line parameter
>> for the placement of the log file.
>
>Yup, XDG_DATA_HOME would work for me; it seems to be rather in line with
>what the XDG states and what Xorg does, as you note.
>
>  https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
>
>WDYT, Efraim & Janneke?

I don't think it's really data, it's not like it belongs in something/share. As another data point keybase writes its (verbose) logs in .cache/keybase.

>
>Ludo’.

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.




Information forwarded to guix-patches <at> gnu.org:
bug#43920; Package guix-patches. (Sat, 24 Oct 2020 22:59:02 GMT) Full text and rfc822 format available.

Message #20 received at 43920 <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 43920 <at> debbugs.gnu.org,
 Efraim Flashner <efraim <at> flashner.co.il>
Subject: Re: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to
 XDG_CACHE_DIR.
Date: Sun, 25 Oct 2020 00:58:21 +0200
Ludovic Courtès writes:

Hello,

> Leo Prikler <leo.prikler <at> student.tugraz.at> skribis:
>
>>> The previous location wasn’t perfect, but the proposed one isn’t
>>> great
>>> either: one can generally assume “rm -rf ~/.cache” won’t lose
>>> anything
>>> that cannot be reconstructed, and the log is something that cannot be
>>> reconstructed.
>> That is actually not part of the XDG specification – it merely states,
>> that non-essential files be put there.  Whether or not one considers
>> the shepherd log essential is debatable.
>
> Right, that’s my interpretation of what “cache” means.

Yes, essential is pretty vague; a cache is something that can be
re-generated.

>> You could alternatively put it under $XDG_DATA_HOME.  Some projects
>> like Xorg seem to do that.  Of course, there always remains the option
>> of having yet another environment variable or command line parameter
>> for the placement of the log file.
>
> Yup, XDG_DATA_HOME would work for me; it seems to be rather in line with
> what the XDG states and what Xorg does, as you note.
>
>   https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
>
> WDYT, Efraim & Janneke?

Data sounds a bit strong (I would consider a database to be data), and
cache is too loose.  Otoh, losing a log can be crucial; so I'd go for
XDG_DATA_HOME.

Janneke

-- 
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com




Information forwarded to guix-patches <at> gnu.org:
bug#43920; Package guix-patches. (Mon, 26 Oct 2020 10:29:02 GMT) Full text and rfc822 format available.

Message #23 received at 43920 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 43920 <at> debbugs.gnu.org,
 "Jan \(janneke\) Nieuwenhuizen" <janneke <at> gnu.org>
Subject: Re: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to
 XDG_CACHE_DIR.
Date: Mon, 26 Oct 2020 11:27:53 +0100
Hi,

Efraim Flashner <efraim <at> flashner.co.il> skribis:

> On October 24, 2020 4:15:33 PM UTC, "Ludovic Courtès" <ludo <at> gnu.org> wrote:

[...]

>>>> The previous location wasn’t perfect, but the proposed one isn’t
>>>> great
>>>> either: one can generally assume “rm -rf ~/.cache” won’t lose
>>>> anything
>>>> that cannot be reconstructed, and the log is something that cannot be
>>>> reconstructed.

[...]

> I don't think it's really data, it's not like it belongs in something/share. As another data point keybase writes its (verbose) logs in .cache/keybase.

To me the question whether it’s OK to lose the log.  In a way, storing
the log in ~/.cache akin to storing it in /tmp.

If we agree on that, then we have the choice between ~/.local/share
aka. XDG_DATA_HOME (like Xorg does), or maybe using ~/.local/var/log or
something similar that goes beyond XDG?

Thoughts?

Naming directories is hard.  :-)

Ludo’.




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 18 Nov 2020 21:36:02 GMT) Full text and rfc822 format available.

Notification sent to Efraim Flashner <efraim <at> flashner.co.il>:
bug acknowledged by developer. (Wed, 18 Nov 2020 21:36:02 GMT) Full text and rfc822 format available.

Message #28 received at 43920-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>,
 "Jan \(janneke\) Nieuwenhuizen" <janneke <at> gnu.org>, 43920-done <at> debbugs.gnu.org
Subject: Re: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to
 XDG_CACHE_DIR.
Date: Wed, 18 Nov 2020 22:35:43 +0100
Hi,

Ludovic Courtès <ludo <at> gnu.org> skribis:

> Efraim Flashner <efraim <at> flashner.co.il> skribis:
>
>> On October 24, 2020 4:15:33 PM UTC, "Ludovic Courtès" <ludo <at> gnu.org> wrote:
>
> [...]
>
>>>>> The previous location wasn’t perfect, but the proposed one isn’t
>>>>> great
>>>>> either: one can generally assume “rm -rf ~/.cache” won’t lose
>>>>> anything
>>>>> that cannot be reconstructed, and the log is something that cannot be
>>>>> reconstructed.
>
> [...]
>
>> I don't think it's really data, it's not like it belongs in something/share. As another data point keybase writes its (verbose) logs in .cache/keybase.
>
> To me the question whether it’s OK to lose the log.  In a way, storing
> the log in ~/.cache akin to storing it in /tmp.
>
> If we agree on that, then we have the choice between ~/.local/share
> aka. XDG_DATA_HOME (like Xorg does), or maybe using ~/.local/var/log or
> something similar that goes beyond XDG?

I pushed a variant of your patch that uses XDG_DATA_HOME instead:

  https://git.savannah.gnu.org/cgit/shepherd.git/commit/?id=c6382a6898f2851d78b675f209787c5ff9ad4320

There’s a now ‘%user-log-dir’ so it’ll be easier to adjust going
forward if we change our mind.

Thanks,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 17 Dec 2020 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 103 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.