From ccd7b05bc78ce386677735346879aef5982dc9c6 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Mon, 5 May 2025 08:43:38 +0100 Subject: [PATCH] Add option to log to stderr UNIX provides file-descriptor 2 for diagnostic output. https://pubs.opengroup.org/onlinepubs/9799919799/ --- cmd/yggdrasil/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/yggdrasil/main.go b/cmd/yggdrasil/main.go index b3c9151d..3c17d0ff 100644 --- a/cmd/yggdrasil/main.go +++ b/cmd/yggdrasil/main.go @@ -63,7 +63,7 @@ func main() { confjson := flag.Bool("json", false, "print configuration from -genconf or -normaliseconf as JSON instead of HJSON") autoconf := flag.Bool("autoconf", false, "automatic mode (dynamic IP, peer with IPv6 neighbors)") ver := flag.Bool("version", false, "prints the version of this build") - logto := flag.String("logto", "stdout", "file path to log to, \"syslog\" or \"stdout\"") + logto := flag.String("logto", "stdout", "file path to log to, \"syslog\", \"stdout\", or \"stderr\"") getaddr := flag.Bool("address", false, "use in combination with either -useconf or -useconffile, outputs your IPv6 address") getsnet := flag.Bool("subnet", false, "use in combination with either -useconf or -useconffile, outputs your IPv6 subnet") getpkey := flag.Bool("publickey", false, "use in combination with either -useconf or -useconffile, outputs your public key") @@ -82,6 +82,8 @@ func main() { switch *logto { case "stdout": logger = log.New(os.Stdout, "", log.Flags()) + case "stderr": + logger = log.New(os.Stderr, "", log.Flags()) case "syslog": if syslogger, err := gsyslog.NewLogger(gsyslog.LOG_NOTICE, "DAEMON", version.BuildName()); err == nil {