Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Logging

Marc Davis edited this page Apr 30, 2020 · 1 revision

Working with search_compiler Logger objects

Search compiler uses sc.logging.Logger objects to manage printing to stdout and writing to log files.

import search_compiler as sc
mylogger = sc.logging.Logger(stdout_enabled, output_file, verbosity)
mylogger.logprint(text, verbosity)

Logger Options

  • stdout_enabled - This is a boolean that defines whether logs should be printed to stdout. The default value is False.
  • output_file - This is a string that provides a filepath that the logger will write to. The default value is None, which causes no file to be written.
  • verbosity - This is the verbosity of the Logger, which controls how much content is logged. The default value is 1. A value of 0 will silence all output, a value of 1 will log the default amount of output, and a value of 2 will log more detailed output. See the section on verbosity below for more information.

Logprint Options

  • text - This is the text that will be logged.
  • verbosity - This is the verbosity of the print call, which is compared to the verbosity of the Logger to decide whether this call is ignored or not. The default value is 1. See the section on verbosity below for more details.

Verbosity Behavior

The amount of content logged is controlled by the verbosity setting on the Logger object. When a logprint call is made, the logprint verbosity represents the importance of the print, with lower values being more important. If the verbosity of the Logger is lower than the verbosity of the logprint, then the logprint call is ignored.

search_compiler uses two levels of logprint calls, with verbosity at 1 and verbosity at 2. If the Logger verbosity is set to 1, the logprint calls with verbosity 1 will be logged, and those with verbosity 2 will be ignored. Setting the Logger verbosity to 2 will cause all logprints to be logged, and setting the Logger verbosity to 1 will cause all logprints to be ignored. Other verbosity levels are supported, but currently not used by search_compiler.