oslog-wrapper

Tags

When writing a LaunchAgent for macos the main option is to direct stdout/stderr to files.

MacOS does have their 'Unified Logging System' but it is not connected to LaunchAgents by default.



It seems like some kind of wrapper could be written so that our LaunchAgent program CLI would look something like this.


<key>ProgramArguments</key>
<array>
<string>oslog-wrapper</string>
<string>--system=somename</string>
<string>--</string>
<string>/path/to/app</string>
<string>--addtional=args</string>
</array>

Need to redirect stdout/stderr to the correct oslog.


forwardLines(from: stdoutPipe, log: { logger.info("\($0, privacy: .public)") })
forwardLines(from: stderrPipe, log: { logger.error("\($0, privacy: .public)") })

Also need to be sure to forward valid signals to the underlying process


forwardSignal(SIGTERM, to: childPID)