Jump to content

Scap/Scap3 structured logging

From Wikitech

The structured logging feature of scap3 was introduced in differential revision D18

The main deploy application now sends all structured log output to a file under scap/log/{git-tag}.log which the new deploy-log utility can tail and filter using a given free-form expression. By default the latter utility will periodically scan the scap/log directory for new files and immediately begin tailing them. It can also be given an explicit log file to parse via the --file option or the latest log file by using --latest; in this case, it will simply filter the entire file for matching records and exit.

As an alternative to the default behavior, you can either specify the log file to parse via the scap deploy-log --file option or choose the newest log file by using scap deploy-log --latest; in this case, it will simply filter the entire file for matching records and exit, rather than watching for more log files to be created.

The default behavior is convenient for monitoring an ongoing deployment from a separate terminal. Simply start scap deploy-log in a separate terminal prior to running scap deploy. Once your deployment starts, scap deploy-log will discover the new log file and immediately begin displaying relevant log messages

Examples

Tail behavior

  • Run deploy-log {expr}
  • Run deploy in a separate terminal
  • Verify that **deploy-log** in the first terminal starts reading the new log file. It should say -- Opening log file: {file}.
  • Verify that only log messages matching the given expression are output.

Latest log file behavior

  • Run deploy.
  • Run deploy-log -l {expr}
  • Verify that only log messages from the latest log file matching the given expression are output.

Single log file behavior

  • Run deploy a couple of times.
  • Run deploy-log -f {log-file} {expr}
  • Verify that only log messages from the given log file matching the given expression are output.