Logging
Logging with RBCli is straightforward - it looks at the config file for logging settings, and instantiates a single, globally accessible Logger object. You can access it within a standard command like this:
Rbcli::log.info { 'These logs can go to STDERR, STDOUT, or a file' }
Enabling Logging
To enable logging, simply set the default values in the config/logging.rb
file:
log_level :info
log_target 'stderr'
log_level
- You can set the default log level using either numeric or standard Ruby logger levels: 0-5, or DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
log_target
- This specifies where the logs will be placed. Valid values are nil (disables logging), 'STDOUT', 'STDERR', or a file path (all as strings).
Userspace Config Overrides
If Userspace Configuration is enabled, these options will also be present in the user's config file to override defaults:
# Log Settings
logger:
log_level: warn # 0-5, or DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
log_target: stderr # STDOUT, STDERR, or a file path