ixa

Module log

Source
Expand description

The log module defines an interface to Ixa’s internal logging facilities. Logging messages about internal behavior of Ixa. This is not to be confused with reporting, which is model-level concept for Ixa users to record data about running models.

Model authors can nonetheless use Ixa’s logging facilities to output messages. This module (re)exports the five logging macros: error!, warn!, info!, debug! and trace! where error! represents the highest-priority log messages and trace! the lowest. To emit a log message, simply use one of these macros in your code:

use ixa::{info};

pub fn do_a_thing() {
    info!("A thing is being done.");
}

Logging is disabled by default. Logging messages can be enabled by passing the command line option --log-level <level>. Log messages can also be controlled programmatically. Logging can be enabled/disabled from code using the functions:

  • enable_logging(): turns on all log messages
  • disable_logging(): turns off all log messages
  • set_log_level(level: LevelFilter): enables only log messages with priority at least level

In addition, per-module filtering of messages can be configured using set_module_filter() / set_module_filters() and remove_module_filter():

use ixa::log::{set_module_filter, remove_module_filter, set_module_filters, LevelFilter,
enable_logging, set_log_level};

pub fn setup_logging() {
    // Enable `info` log messages globally.
    set_log_level(LevelFilter::Info);
    // Disable Ixa's internal logging messages.
    set_module_filter("ixa", LevelFilter::Off);
    // Enable all log messages for the `transmission_manager` module.
    set_module_filter("transmission_manager", LevelFilter::Trace);
}

Macros§

  • Logs a message at the debug level.
  • Logs a message at the error level.
  • Logs a message at the info level.
  • Logs a message at the trace level.
  • Logs a message at the warn level.

Enums§

  • An enum representing the available verbosity level filters of the logger.

Functions§

  • Disables logging completely. Equivalent to set_log_level(LevelFilter::Off).
  • Enables the logger with no global level filter / full logging. Equivalent to set_log_level(LevelFilter::Trace).
  • Removes a module-specific level filter for the given module path. The global level filter will apply to the module.
  • Sets the global log level. A global filter level of LevelFilter::Off disables logging.
  • Sets a level filter for the given module path.
  • Sets the level filters for a set of modules according to the provided map. Use this instead of set_module_filter() to set filters in bulk.