Read subsystem, category, and log level values from environment #70
Replies: 1 comment 1 reply
-
An alternative/additional method of reducing repetitive command arguments might be to leverage option aliasing support provided by the
To log a message from a script—or the command-line—using the aliased options configured above: flog --my-script 'healthy' Which replaces the more verbose: flog -s com.my-domain.my-script -c health 'healthy' |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The problem
Given that
flog
is primarily intended for use in shell scripts, expressing command arguments for each invocation can lead to repetitive code:This is particularly apparent when considering the subsystem and category names1.
🙄
Proposal
Add support for reading default subsystem, category, and log level values from the shell environment, allowing command-line arguments to override them when provided:
FLOG_CATEGORY
FLOG_SUBSYSTEM
FLOG_LOG_LEVEL
This could reduce the repetitiveness of command arguments significantly:
Function-scoped variables (shown here using
declare
in abash
script) could be used to set the category name and distinguish functional aspects of the script, whilst reducing repetitive command arguments within those functions:Footnotes
Apple has this to say about subsystem and category naming:
Source:
os_log_create(3)
↩Beta Was this translation helpful? Give feedback.
All reactions