From 85ef3e20116c192a69ce155087b79f24b268367b Mon Sep 17 00:00:00 2001 From: Christopher Nielsen Date: Sun, 20 Aug 2023 07:59:48 -0400 Subject: [PATCH 1/2] startupitem: add new option startupitem.logfile.stderr Fixes: https://trac.macports.org/ticket/67955 --- src/port1.0/portstartupitem.tcl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/port1.0/portstartupitem.tcl b/src/port1.0/portstartupitem.tcl index 69ebb1b21b..98c561bf43 100644 --- a/src/port1.0/portstartupitem.tcl +++ b/src/port1.0/portstartupitem.tcl @@ -53,8 +53,15 @@ # We create and destroy the pidfile to track the pid we receive from the executable # # startupitem.logfile logpath -# Log to the specified file -- if not specified then output to /dev/null -# - for launchd, just set this as the standard out key +# Log stdout to the specified logfile +# - If not specified, then output to /dev/null +# - For launchd, set the stdout plist key +# +# startupitem.logfile.stderr logpath +# Log stderr to the specified logfile +# - If not specified, defaults to startupitem.logfile +# - If cleared, disables stderr logging +# - For launchd, set the stderr plist key # # startupitem.logevents yes/no # Log events to the log @@ -84,7 +91,8 @@ options startupitems startupitem.autostart startupitem.debug \ startupitem.create startupitem.custom_file \ startupitem.executable startupitem.group \ startupitem.init startupitem.install startupitem.location \ - startupitem.logevents startupitem.logfile startupitem.name \ + startupitem.logevents startupitem.logfile \ + startupitem.logfile.stderr startupitem.name \ startupitem.netchange startupitem.pidfile startupitem.plist \ startupitem.requires startupitem.restart startupitem.start \ startupitem.stop startupitem.type startupitem.uniquename \ @@ -100,6 +108,7 @@ default startupitem.install {$system_options(startupitem_install)} default startupitem.location LaunchDaemons default startupitem.logevents no default startupitem.logfile "" +default startupitem.logfile.stderr {${startupitem.logfile}} default startupitem.name {${subport}} default startupitem.netchange no default startupitem.pidfile "" @@ -143,8 +152,8 @@ proc portstartupitem::get_startupitem_type {} { proc portstartupitem::foreach_startupitem {body} { global startupitems set vars [list autostart create custom_file debug executable group \ - init install location logevents logfile name netchange \ - pidfile plist requires restart start stop type \ + init install location logevents logfile logfile.stderr \ + name netchange pidfile plist requires restart start stop type \ uniquename user daemondo.verbosity] array set startupitems_dict {} @@ -491,6 +500,10 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} { puts ${plist} "StandardOutPath$si(logfile)" } + if {$si(logfile.stderr) ne ""} { + puts ${plist} "StandardErrorPath$si(logfile.stderr)" + } + if {$si(debug)} { puts ${plist} "Debug" } From a8b2d1f0a7fee2f7a1542c79f6144ec5cd6f1b13 Mon Sep 17 00:00:00 2001 From: Christopher Nielsen Date: Sun, 20 Aug 2023 08:47:44 -0400 Subject: [PATCH 2/2] manpages: portfile: document keyword startupitem.logfile.stderr --- doc/portfile.7 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/portfile.7 b/doc/portfile.7 index 06651173c6..64bab23024 100644 --- a/doc/portfile.7 +++ b/doc/portfile.7 @@ -1996,6 +1996,20 @@ standard output from the daemon may also be directed to the logfile. .br .Sy Example: .Dl startupitem.logfile ${prefix}/var/log/mydaemon.log +.It Ic startupitem.logfile.stderr +Path to a logfile for capturing standard error output from the daemon. +.br +.Sy Type: +.Em optional +.br +.Sy Default: +.Em startupitem.logfile +.br +.Sy Values: +.Em path +.br +.Sy Example: +.Dl startupitem.logfile.stderr ${prefix}/var/log/mydaemon.log .It Ic startupitem.logevents Control whether or not to log events to the log file. If this option is set, events with timestamps are logged to the logfile.