NAME
maclog - write to the macOS unified log from the command line
VERSION
version 0.0.1
USAGE
Simple version:
maclog --message 'Hello world!'
All the bells and whistles:
maclog --subsystem com.phoenixtrap.maclog \
--level info \
--category general \
--format "Hello %s number %i" \
--message 'world' \
--message 42
Arbitrary number of message strings without --message:
maclog --format "Hello %s number %i" -- world 42
DESCRIPTION
This script provides an easy way to add entries to the macOS unified log from the command line, a feat normally reserved for users of Apple's Swift and Objective-C APIs.
It is a thin wrapper around Log::Any::Adapter::MacOS::OSLog.
REQUIRED ARGUMENTS
- --subsystem
-
The name of the subsystem field in the log entry in reverse DNS order. Defaults to
com.phoenixtrap.maclog
. - --level
-
The desired logging level. As this command script is a thin wrapper around Log::Any::Adapter::MacOS::OSLog, it uses the following level names, mapped to corresponding macOS os_log(3) levels:
trace: os_log_debug(3)
debug: os_log_debug(3)
info: os_log_info(3)
notice: os_log_info(3)
warning: os_log_fault(3)
error: os_log_error(3)
critical: os_log(3)
alert: os_log(3)
emergency: os_log(3)
Defaults to
info
. - --category
-
The desired category field in the unified log entry. Note that this is not related to Log::Any's notion of categories.
Defaults to
general
.
OPTIONS
- --format
-
A sprintf format describing where and how to format individual message values. If no --format is specified, message values will be joined together with spaces.
- --message
-
Can be specified multiple times. Each --message value will be filled into the corresponding formatting code in the format. You may instead provide one or more message values at the end of the command preceded by
--
. - --help
-
Prints helpful information about how to use this command script.
- --man
-
Prints this command script's entire manual page.
DIAGNOSTICS
The entire point of this command script is diagnostics. Use the macOS log(1) command or the Console app to view the results.
EXIT STATUS
Exits 0 on success or viewing the help/manual page, 1 if there is a problem with the command line arguments. Other exit values may occur if there is a problem with code execution.
CONFIGURATION
None.
DEPENDENCIES
INCOMPATIBILITIES
Because this command script relies on the macOS unified logging system introduced in macOS Sierra version 10.12, it is incompatible with earlier versions of OS X, Mac OS X, the classic Mac OS, and all other non-Apple platforms (Microsoft Windows, Linux, other Unixes, etc.).
BUGS AND LIMITATIONS
Undoubtedly. Open an issue in the tracker.
SUPPORT
Source code and issue tracker: https://codeberg.org/mjgardner/perl-Log-Any-Adapter-MacOS-OSLog
SEE ALSO
The Eclectic Light Company's blowhole
command line utility, available at https://eclecticlight.co/consolation-t2m2-and-log-utilities/, performs a similar function but does not enable the user to change the subsystem or category.
AUTHOR
Mark Gardner <mjgardner@cpan.org>
LICENSE AND COPYRIGHT
This software is copyright (c) 2025 by Mark Gardner.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.