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

Debug Logging

Matt Butrovich edited this page Aug 22, 2018 · 3 revisions

This page outlines:

  1. General summary of the logging support
  2. Controlling log levels and the log level default
  3. How to add logging support for a new module

Overview

The logging module provides the ability to control log output, per "module". This allows log output to be controlled such that one more modules of interest generate the desired level of log output, while other modules generate little or none. Verbosity for each module can be controlled at run time.

Log output destination

The default configuration is for all modules to send output to a common log destination. The default destination is the console.

Log levels

The following log levels are provided:

Level Name
0 TRACE
1 DEBUG
2 INFO
3 WARN
4 ERR
6 OFF

The default log level setting is INFO, i.e messages of level INFO, WARN and ERR are logged. Messages of level TRACE and DEBUG are discarded. The level may be adjusted at run time at any time after the module is initialized. Each module's log level can be independently adjusted.

Adding new log points

Log points are added using module specific macros. For example, to add a log message for the storage namespace (i.e. the storage module) use one of the storage log macros, e.g. STORAGE_LOG_INFO

Adding logging for a new module

By convention, each namespace has an associated logging module. To add support for a new logging module (i.e. namespace):

  • In src/include/loggers, copy storage_logger.h to create a new logger header file, e.g. mymodule_logger.h. Edit the contents to reflect the name of the module.
  • In terrier.cpp, main, add the initialization of the new logger. Set the default level for the new logger if desired. The level, if not initialized, is INFO.