Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startupitem: add new option startupitem.logfile.stderr, for capturing stderr #296

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/portfile.7
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 18 additions & 5 deletions src/port1.0/portstartupitem.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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 ""
Expand Down Expand Up @@ -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 {}
Expand Down Expand Up @@ -491,6 +500,10 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
puts ${plist} "<key>StandardOutPath</key><string>$si(logfile)</string>"
}

if {$si(logfile.stderr) ne ""} {
puts ${plist} "<key>StandardErrorPath</key><string>$si(logfile.stderr)</string>"
}

if {$si(debug)} {
puts ${plist} "<key>Debug</key><true/>"
}
Expand Down
Loading