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
[1;38;5;11mCreating A Project With Resources
[1;38;5;11m────────────────────────────────────────────────────────────────────────────────
[0m
This plugin is helper for creating a project directory, incl. required local
resources. Your system remains unchanged, except <project_dir> and
<conda_prefix>.
[0m
It provides an [0;38;5;5minstall[0m action (implicitely by providing the
--init_resource_match or --init_at switch)
[0m
Default action is: [0;38;5;5mlist[0m (show installable resources, -m <match> filters).
[0m
At install we will (re-)initialize a "project_dir", at location given with
--init_at (default: '.'), incl:
[0m
[0;38;5;5m❖ [0mInstalling available resources, like databases and tools within a given
directory (conda_prefix)
[0m
[0;38;5;5m❖ [0mCreating resource start wrappers in <project_dir>/bin
[0m
[0;38;5;5m❖ [0mGenerating default config when required
[0m
[0;38;5;5m❖ [0mOptionally generating systemd unit files (e.g. via: --init_create_all_units)
[0m
[0;38;5;5m❖ [0mInstances support: export <name>_instances=x before running and you'll get x
systemd units created, for startable commands.
[0;38;5;5m
[0;38;5;5m [0;38;5;5mExample: export client_instances=10; ops p -irm client -icau
[0;38;5;5m [0;38;5;5m(Name of a resource: ops p [-m <match>])[0m
[0m
[0;38;5;5m❖ [0mAny other parametrization: Via environ variables Check key environ vars in
list output and also doc text.
[0m
Privilege escalation is not required for any of these steps.
[0m
All supported command line flags [matching [1;32mlog[0m]:
[1;34mabsl.logging
[0;32m [1;33malsologtostderr [0;31mFalse[0;38;5;245m
also log to stderr?
[0;32m [1;33mlog_dir [0;31m''[0;38;5;245m
directory to write logfiles into
[0;32m [1;33mlogger_levels [0;31m''[0;38;5;245m
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`
[0;32m [1;33mlogtostderr [0;31mFalse[0;38;5;245m
Should only log to stderr?
[0;32m [1;33mshowprefixforinfo [0;31mTrue[0;38;5;245m
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.
[0;32m [1;33mstderrthreshold [0;31mfatal[0;38;5;245m
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.
[0;32mv [1;33mverbosity [0;31m-1[0;38;5;245m
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.
[1;34mdevapp.tools
[0;32mdasdi [1;33msensitive_data_identifiers [0;31mpass.*|.*secret.*[0;38;5;245m
Regexp which helps identify keys carrying sensitive information (for filtering out of logs). Case insensitive matching.
[1;34mstructlogging.sl
[0;32mlatn [1;33mlog_add_thread_name [0;31mFalse[0;38;5;245m
Add name of thread
[0;32mldcs [1;33mlog_dev_coljson_style [0;31mdark[0;38;5;245m
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>
[0;32mldfc [1;33mlog_dev_fmt_coljson [0;31mjson,payload[0;38;5;245m
List of keys to log as json.
[0;32mlf [1;33mlog_fmt [0;31mauto[0;38;5;245m
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.
[0;32mll [1;33mlog_level [0;31m20[0;38;5;245m
Log level (10: debug, 20: info, ...). You may also say log_level=error
[0;32mlsf [1;33mlog_stack_filter [0;31mfn not contains frozen and fn not contains /rx/[0;38;5;245m
When logging error tracebacks this is an optional filter. Keywords:fn: filename, frame: frame nr, line: line nr, name: name of callable [0;38;5;241m
Example: fn contains project and frame lt 1 (axiros/pycond expression)
[0;32mlsmf [1;33mlog_stack_max_frames [0;31m3[0;38;5;245m
Maximum Frames Shown in Terminal Stack Traces
[0;32mltln [1;33mlog_thread_local_names [0;31mFalse[0;38;5;245m
Prefer thread local logger_name, when set
[0;32mltf [1;33mlog_time_fmt [0;31m%m-%d %H:%M:%S[0;38;5;245m
Log time format. Shortcuts: "ISO", "dt"
[1;34mops_devapp.project
[0;32mappc [1;33madd_post_process_cmd [0;31m''[0;38;5;245m
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.
[0;32m [1;33mlog_resources_fully [0;31mFalse[0;38;5;245m
Always output all settings of resources when logging
[0m