Several options imply --syslog, without there being a way to disable it again. This commit adds that option.
This is useful, for instance, when running `git daemon` as a systemd service with --inetd. systemd connects stderr to the journal by default, so logging to stderr is useful. On the other hand, log messages sent via syslog also reach the journal eventually, but run the risk of being processed at a time when the `git daemon` process has already exited (especially if the process was very short-lived, e.g. due to client error), so that the journal can no longer read its cgroup and attach the message to the correct systemd unit. See systemd/systemd#2913 [1]. [1]: https://github.com/systemd/systemd/issues/2913 Signed-off-by: Lucas Werkmeister <m...@lucaswerkmeister.de> --- Notes: I decided not to add the option to git-daemon's --help output, since the similar --no-informative-errors option is also not listed there. Let me know if it should be added. Feel free to remove the part about systemd from the commit message if you feel it doesn't need to be included. Documentation/git-daemon.txt | 6 ++++-- daemon.c | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt index 3c91db7be..dfd6ce03c 100644 --- a/Documentation/git-daemon.txt +++ b/Documentation/git-daemon.txt @@ -8,7 +8,7 @@ git-daemon - A really simple server for Git repositories SYNOPSIS -------- [verse] -'git daemon' [--verbose] [--syslog] [--export-all] +'git daemon' [--verbose] [--[no-]syslog] [--export-all] [--timeout=<n>] [--init-timeout=<n>] [--max-connections=<n>] [--strict-paths] [--base-path=<path>] [--base-path-relaxed] [--user-path | --user-path=<path>] @@ -109,9 +109,11 @@ OPTIONS Maximum number of concurrent clients, defaults to 32. Set it to zero for no limit. ---syslog:: +--[no-]syslog:: Log to syslog instead of stderr. Note that this option does not imply --verbose, thus by default only error conditions will be logged. + `--no-syslog` is the default, but may be given explicitly to override + the implicit `--syslog` of an earlier `--inetd` or `--detach` option. --user-path:: --user-path=<path>:: diff --git a/daemon.c b/daemon.c index e37e343d0..d59fef6d6 100644 --- a/daemon.c +++ b/daemon.c @@ -1300,6 +1300,10 @@ int cmd_main(int argc, const char **argv) log_syslog = 1; continue; } + if (!strcmp(arg, "--no-syslog")) { + log_syslog = 0; + continue; + } if (!strcmp(arg, "--export-all")) { export_all_trees = 1; continue; -- 2.16.0