unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Efraim Flashner <efraim@flashner.co.il>
To: 43920@debbugs.gnu.org
Cc: Efraim Flashner <efraim@flashner.co.il>
Subject: [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to XDG_CACHE_DIR.
Date: Sun, 11 Oct 2020 12:20:17 +0300	[thread overview]
Message-ID: <20201011092017.31901-1-efraim@flashner.co.il> (raw)

* 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





             reply	other threads:[~2020-10-11  9:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-11  9:20 Efraim Flashner [this message]
2020-10-22 14:23 ` [bug#43920] [SHEPHERD PATCH] shepherd: Move log file to XDG_CACHE_DIR Ludovic Courtès
2020-10-23 22:17 ` Leo Prikler
2020-10-24 16:15   ` Ludovic Courtès
2020-10-24 16:51     ` Efraim Flashner
2020-10-26 10:27       ` Ludovic Courtès
2020-11-18 21:35         ` bug#43920: " Ludovic Courtès
2020-10-24 22:58     ` [bug#43920] " Jan Nieuwenhuizen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201011092017.31901-1-efraim@flashner.co.il \
    --to=efraim@flashner.co.il \
    --cc=43920@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).