Skip to content

Logging¤

You have a rich structured logging system, backed by structlog:

The features we show by matching the help full (-hf) output of an arbitrary app (here ops project) on the match string "log":

$ ops project -hf log


Creating A Project With Resources
────────────────────────────────────────────────────────────────────────────────

This plugin is helper for creating a project directory, incl. required local
resources. Your system remains unchanged, except <project_dir> and
<conda_prefix>.

It provides an install action (implicitely by providing the
--init_resource_match or --init_at switch)

Default action is: list (show installable resources, -m <match> filters).

At install we will (re-)initialize a "project_dir", at location given with
--init_at (default: '.'), incl:

❖ Installing available resources, like databases and tools within a given
  directory (conda_prefix)

❖ Creating resource start wrappers in <project_dir>/bin

❖ Generating default config when required

❖ Optionally generating systemd unit files (e.g. via: --init_create_all_units)

❖ Instances support: export <name>_instances=x before running and you'll get x
  systemd units created, for startable commands.

  Example: export client_instances=10; ops p -irm client -icau
  (Name of a resource: ops p [-m <match>])

❖ Any other parametrization: Via environ variables Check key environ vars in
  list output and also doc text.

Privilege escalation is not required for any of these steps.


All supported command line flags [matching log]:
absl.logging
        alsologtostderr          False
also log to stderr? 
        log_dir                  ''
directory to write logfiles into 
        logger_levels            ''
Specify log level of loggers. The format is a CSV list of `name:level`. Where `name` is the logger name used with `logging.getLogger()`, and `level` is a level name  (INFO, DEBUG, etc). e.g. `myapp.foo:INFO,other.logger:DEBUG` 
        logtostderr              False
Should only log to stderr? 
        showprefixforinfo        True
If False, do not prepend prefix to info messages when it's logged to stderr, --verbosity is set to INFO level, and python logging is used. 
        stderrthreshold          fatal
log messages at this level, or more severe, to stderr in addition to the logfile.  Possible values are 'debug', 'info', 'warning', 'error', and 'fatal'.  Obsoletes --alsologtostderr. Using --alsologtostderr cancels the effect of this flag. Please also note that this flag is subject to --verbosity and requires logfile not be stderr. 
v       verbosity                -1
Logging verbosity level. Messages logged at this level or lower will be included. Set to 1 for debug logging. If the flag was not set or supplied, the value will be changed from the default of -1 (warning) to 0 (info) after flags are parsed. 
devapp.tools
dasdi   sensitive_data_identifiers pass.*|.*secret.*
Regexp which helps identify keys carrying sensitive information (for filtering out of logs). Case insensitive matching. 
structlogging.sl
latn    log_add_thread_name      False
Add name of thread 
ldcs    log_dev_coljson_style    dark
 Pygments style for colorized json. To use the 16 base colors and leave it to the terminal palette how to render choose light or dark <abap|algol|algol_nu|arduino|autumn|borland|bw|colorful|dark|default|dracula|emacs|friendly|friendly_grayscale|fruity|gruvbox-dark|gruvbox-light|igor|inkpot|light|lilypond|lovelace|manni|material|monokai|murphy|native|one-dark|paraiso-dark|paraiso-light|pastie|perldoc|rainbow_dash|rrt|sas|solarized-dark|solarized-light|stata|stata-dark|stata-light|tango|trac|vim|vs|xcode|zenburn>
ldfc    log_dev_fmt_coljson      json,payload
List of keys to log as json. 
lf      log_fmt                  auto
Force a log format. 0: off, 1: auto, 2: plain, 3: plain_no_colors, 4: json. Note: This value can be set away from auto via export log_fmt as well. 
ll      log_level                20
Log level (10: debug, 20: info, ...). You may also say log_level=error 
lsf     log_stack_filter         fn not contains frozen and fn not contains /rx/
When logging error tracebacks this is an optional filter. Keywords:fn: filename, frame: frame nr, line: line nr, name: name of callable  
Example: fn contains project and frame lt 1 (axiros/pycond expression)
lsmf    log_stack_max_frames     3
Maximum Frames Shown in Terminal Stack Traces 
ltln    log_thread_local_names   False
Prefer thread local logger_name, when set 
ltf     log_time_fmt             %m-%d %H:%M:%S
Log time format. Shortcuts: "ISO", "dt" 
ops_devapp.project
appc    add_post_process_cmd     ''
Add this to all commands which have systemd service units. Intended for output redirection. Not applied when stdout is a tty.
Example: -appc='2>&1 | rotatelogs -e -n1 "$logfile" 1M' ($logfile defined in wrapper -> use single quotes).
Tip: Use rotatelogs only on powers of 10 - spotted problems with 200M. Use 100M or 1G in that case. 
        log_resources_fully      False
Always output all settings of resources when logging 

Back to top