flog
is a command-line tool for sending log messages to Apple's unified logging system and is primaily intended for use in scripts.
Install with Homebrew:
brew install marcransome/tap/flog
To log a message using the default
log level:
flog '<message>'
Optionally specify a subsystem and category using the -s|--subsystem
and -c|--category
options:
flog -s uk.co.fidgetbox -c general 'informational message'
Override the default log level using the -l|--level
option and one of the values info
, debug
, error
or fault
:
flog -l fault -s uk.co.fidgetbox -c general 'unrecoverable failure'
Warning: Log message strings are public by default and can be read using the
log(1)
command or Console app. To mark a message as private add the-p|--private
option to the command. Doing so will redact the message string, which will be shown as'<private>'
when accessed using the methods previously mentioned. Device Management Profiles can be used to grant access to private log messages.
Refer to the log(1)
man page provided on macOS-based systems for extensive documentation on how to access system wide log messages, or alternatively use the Console app.
Here's an example log stream in Console, filtered by subsystem name, showing messages generated by flog
:
And here's a similar log stream viewed with Apple's log(1)
command:
- macOS (
11.x
or later) - A C17 compiler
- CMake (
3.22
or later)
To perform an out-of-source build from the project directory:
cmake -S . -B build
cmake --build build
- Trunk icon made by Freepik from www.flaticon.com
flog
is provided under the terms of the MIT License.
Email me at [email protected] or tweet @marcransome.