diff mbox series

[bug#71118,2/5] services: tor: Log to stderr rather than syslog.

Message ID e1fe5dcf2571fcf24a2187ea0d2809db5ff32c8c.1716386553.git.ludo@gnu.org
State New
Headers show
Series More service logging to stderr | expand

Commit Message

Ludovic Courtès May 22, 2024, 2:53 p.m. UTC
* gnu/services/networking.scm (tor-configuration->torrc): Change ‘Log’
directive to ‘stderr’.
(tor-shepherd-service): Remove /dev/log file system mapping.

Change-Id: I2e33ad8033f884ce59d929a4181172325331efe0
---
 gnu/services/networking.scm | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Maxim Cournoyer May 22, 2024, 5:28 p.m. UTC | #1
Hi Ludovic,

Ludovic Courtès <ludo@gnu.org> writes:

> * gnu/services/networking.scm (tor-configuration->torrc): Change ‘Log’
> directive to ‘stderr’.
> (tor-shepherd-service): Remove /dev/log file system mapping.
>
> Change-Id: I2e33ad8033f884ce59d929a4181172325331efe0
> ---
>  gnu/services/networking.scm | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
> index 8e64e529abf..378e117a869 100644
> --- a/gnu/services/networking.scm
> +++ b/gnu/services/networking.scm
> @@ -1001,7 +1001,7 @@ (define (tor-configuration->torrc config)
>                 (display "\
>  ### These lines were generated from your system configuration:
>  DataDirectory /var/lib/tor
> -Log notice syslog\n" port)
> +Log notice stderr\n" port)
>                 (when (eq? 'unix '#$socks-socket-type)
>                   (display "\
>  SocksPort unix:/var/run/tor/socks-sock
> @@ -1046,9 +1046,6 @@ (define (tor-shepherd-service config)
>                                     (source "/var/lib/tor")
>                                     (target source)
>                                     (writable? #t))
> -                                  (file-system-mapping
> -                                   (source "/dev/log") ;for syslog
> -                                   (target source))

I see no functional change here; do I understand that Shepherd 1.0 will
now log (by default?) to /dev/error (stderr) instead of /dev/log
(syslog)?  What is the rationale for such change?
Ludovic Courtès May 23, 2024, 9:24 a.m. UTC | #2
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> * gnu/services/networking.scm (tor-configuration->torrc): Change ‘Log’
>> directive to ‘stderr’.
>> (tor-shepherd-service): Remove /dev/log file system mapping.
>>
>> Change-Id: I2e33ad8033f884ce59d929a4181172325331efe0

[...]

> I see no functional change here; do I understand that Shepherd 1.0 will
> now log (by default?) to /dev/error (stderr) instead of /dev/log
> (syslog)?  What is the rationale for such change?

Shepherd by itself doesn’t make any decision; it’s up to the service to
choose whether to log to stdout/stderr or to syslog.

As I wrote in the cover letter at <https://issues.guix.gnu.org/71118>,
Shepherd 0.10 already does a good job at handling logs, which makes
gives less of an incentive to use syslogd; on top of that, 1.0 (current
‘devel’ branch) can display messages logged to stderr/stdout directly at
the command line:

--8<---------------cut here---------------start------------->8---
$ sudo /run/current-system/profile/bin/herd status guix-publish
Status of guix-publish:
  It is running since Tue 21 May 2024 08:44:57 AM CEST (2 days ago).
  PID 518 running: /gnu/store/12jb83hlngklkymn52yzaw7kldr2qiwp-guix-1.4.0-20.37719d3/bin/guix publish -u guix-publish -p 8123 -C zstd:3 -C gzip:3 --nar-path=nar --listen=0.0.0.0 --advertise
  It is enabled.
  Provides (guix-publish).
  Requires (user-processes guix-daemon avahi-daemon).
  Will be respawned.
  Log file: /var/log/guix-publish.log.

Recent messages:
  2024-05-21 10:56:10 In web/request.scm:
  2024-05-21 10:56:10    205:32  4 (read-request #<closed: file 7f5f48418af0> _)
  2024-05-21 10:56:10 In web/http.scm:
  2024-05-21 10:56:10   1158:12  3 (read-request-line _)
  2024-05-21 10:56:10    1066:2  2 (parse-request-uri _ _ _)
  2024-05-21 10:56:10 In ice-9/boot-9.scm:
  2024-05-21 10:56:10   1685:16  1 (raise-exception _ #:continuable? _)
  2024-05-21 10:56:10   1685:16  0 (raise-exception _ #:continuable? _)
  2024-05-21 10:56:10 .Bad request: Invalid URI: 85.94.204.153:31204
  2024-05-21 10:56:10 
--8<---------------cut here---------------end--------------->8---

It’s a slight quality-of-life improvement.

Thanks,
Ludo’.
Maxim Cournoyer May 24, 2024, 12:44 p.m. UTC | #3
Hi Ludovic,

Ludovic Courtès <ludo@gnu.org> writes:

> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>>> * gnu/services/networking.scm (tor-configuration->torrc): Change ‘Log’
>>> directive to ‘stderr’.
>>> (tor-shepherd-service): Remove /dev/log file system mapping.
>>>
>>> Change-Id: I2e33ad8033f884ce59d929a4181172325331efe0
>
> [...]
>
>> I see no functional change here; do I understand that Shepherd 1.0 will
>> now log (by default?) to /dev/error (stderr) instead of /dev/log
>> (syslog)?  What is the rationale for such change?
>
> Shepherd by itself doesn’t make any decision; it’s up to the service to
> choose whether to log to stdout/stderr or to syslog.

I see.

> As I wrote in the cover letter at <https://issues.guix.gnu.org/71118>,
> Shepherd 0.10 already does a good job at handling logs, which makes
> gives less of an incentive to use syslogd; on top of that, 1.0 (current
> ‘devel’ branch) can display messages logged to stderr/stdout directly at
> the command line:
>
> $ sudo /run/current-system/profile/bin/herd status guix-publish
> Status of guix-publish:
>   It is running since Tue 21 May 2024 08:44:57 AM CEST (2 days ago).
>   PID 518 running: /gnu/store/12jb83hlngklkymn52yzaw7kldr2qiwp-guix-1.4.0-20.37719d3/bin/guix publish -u guix-publish -p 8123 -C zstd:3 -C gzip:3 --nar-path=nar --listen=0.0.0.0 --advertise
>   It is enabled.
>   Provides (guix-publish).
>   Requires (user-processes guix-daemon avahi-daemon).
>   Will be respawned.
>   Log file: /var/log/guix-publish.log.
>
> Recent messages:
>   2024-05-21 10:56:10 In web/request.scm:
>   2024-05-21 10:56:10    205:32  4 (read-request #<closed: file 7f5f48418af0> _)
>   2024-05-21 10:56:10 In web/http.scm:
>   2024-05-21 10:56:10   1158:12  3 (read-request-line _)
>   2024-05-21 10:56:10    1066:2  2 (parse-request-uri _ _ _)
>   2024-05-21 10:56:10 In ice-9/boot-9.scm:
>   2024-05-21 10:56:10   1685:16  1 (raise-exception _ #:continuable? _)
>   2024-05-21 10:56:10   1685:16  0 (raise-exception _ #:continuable? _)
>   2024-05-21 10:56:10 .Bad request: Invalid URI: 85.94.204.153:31204
>   2024-05-21 10:56:10 
>
> It’s a slight quality-of-life improvement.

I agree that's more convenient than grepping /var/log/messages.

Thanks for explaining and for the Shepherd improvements!
diff mbox series

Patch

diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 8e64e529abf..378e117a869 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -1001,7 +1001,7 @@  (define (tor-configuration->torrc config)
                (display "\
 ### These lines were generated from your system configuration:
 DataDirectory /var/lib/tor
-Log notice syslog\n" port)
+Log notice stderr\n" port)
                (when (eq? 'unix '#$socks-socket-type)
                  (display "\
 SocksPort unix:/var/run/tor/socks-sock
@@ -1046,9 +1046,6 @@  (define (tor-shepherd-service config)
                                    (source "/var/lib/tor")
                                    (target source)
                                    (writable? #t))
-                                  (file-system-mapping
-                                   (source "/dev/log") ;for syslog
-                                   (target source))
                                   (file-system-mapping
                                    (source "/var/run/tor")
                                    (target source)