You may use blowhole
.
blowhole
is a command-line device that takes a string as an argument and sends it to the unified logging system. It’s supported, in several releaes, from Sierra (10.12) as much as Sonoma (14).
The right way to use it
(Examined on macOS Catalina 10.15.5)
Modify the ProgramArguments
array in your .plist
file like this:
ProgramArguments
/bin/bash
-c
COMMAND OPTIONS 2> >(whereas learn; do /path/to/blowhole -e "$REPLY"; achieved) | whereas learn; do /path/to/blowhole -d "$REPLY"; achieved
the place COMMAND OPTIONS
is the command you wish to execute, adopted by any desired choices.
Right here, I make use of bash
‘s help for redirection (2>
), course of substitution (>()
) and pipelines (|
) to:
- kind out the command’s commonplace error and commonplace output
- course of them individually inside two
whereas
loops. The primarywhereas
loop runsblowhole -e
to log commonplace error with an “Error” degree:
Error blowhole: [co.eclecticlight.blowhole:general] Blowhole: STANDARD ERROR MESSAGES
and the second runs blowhole -d
to log commonplace output with a “Default” degree:
Default blowhole: [co.eclecticlight.blowhole:general] Blowhole: STANDARD OUTPUT MESSAGES
(Since blowhole
cannot learn from commonplace enter, we want whereas
loops to feed it a line of enter at a time.)
The blowhole: [co.eclecticlight.blowhole:general] Blowhole:
string isn’t configurable, however you possibly can add a prefix of your option to the logged messages. For instance, because you point out offlineimap
in your query:
/path/to/blowhole -d "offlineimap stdout: $REPLY";
and:
/path/to/blowhole -e "offlineimap stderr: $REPLY";
You’ll be able to learn log entries with sudo log present | grep blowhole:normal
or sudo log present | grep offlineimap
, when you added the custom-made prefix. To learn log entries as they’re generated, in a fashion just like tail -f
, use present stream
as a substitute.
Alternatively, you possibly can wrap the command you wish to execute in a shell script in order that blowhole
logs the command’s commonplace output and error in a manner just like above. That is handy if you wish to run some code previous to executing the precise command:
#!/bin/bash
# Add the code you wish to execute previous to the precise command right here
COMMAND ARGUMENTS
> >(
whereas learn; do
/path/to/blowhole -d "$REPLY";
achieved)
2> >(
whereas learn; do
/path/to/blowhole -e "$REPLY";
achieved)
You’ll be able to then configure the ProgramArguments
array of your .plist
file to run the script as a substitute of your command:
ProgramArguments
/bin/bash
/path/to/script.sh
The place to get it from
You’ll be able to obtain blowhole
from its product web page or instantly with these hyperlinks:
- Blowhole 9: Intel-only for Sierra (10.12) to Catalina (10.15)
- Blowhole 10a: Common binary for Sierra (10.12) to Ventura (13)
- Blowhole 11: Common binary for Massive Sur (11) tp Sonoma (14)
This system is offered as a signed, hardened and notarized executable (as required by Catalina and later) and as an Installer package deal.