yade.log module

The yade.log module serves as an interface to yade logging framework implemented on top of boost::log. For full documentation see debugging section. Example usage in python is as follows:

import yade.log
yade.log.setLevel('PeriTriaxController',yade.log.TRACE)

Example usage in C++ is as follows:

LOG_WARN("Something: "<<something)
yade._log.defaultConfigFileName() → str
Returns:the default log config file, which is loaded at startup, if it exists.
yade._log.getAllLevels() → dict
Returns:A python dictionary with all known loggers in yade. Those without a debug level set will have value -1 to indicate that Default filter log level is to be used for them.
yade._log.getDefaultLogLevel() → int
Returns:The current Default filter log level.
yade._log.getMaxLevel() → int
Returns:the MAX_LOG_LEVEL of the current yade build.
yade._log.getUsedLevels() → dict
Returns:A python dictionary with all used log levels in yade. Those without a debug level (value -1) are omitted.
yade._log.readConfigFile((str)arg1) → None

Loads the given configuration file.

Parameters:fname (str) – the config file to be loaded.
yade._log.resetOutputStream() → None

Resets log output stream to default state: all logs are printed on std::clog channel, which usually redirects to std::cerr.

yade._log.saveConfigFile((str)arg1) → None

Saves log config to specified file.

Parameters:fname (str) – the config file to be saved.
yade._log.setDefaultLogLevel((int)arg1) → None
Parameters:level (int) – Sets the Default filter log level, same as calling log.setLevel("Default",level).
yade._log.setLevel((str)arg1, (int)arg2) → None

Set filter level (constants TRACE (6), DEBUG (5), INFO (4), WARN (3), ERROR (2), FATAL (1), NOFILTER (0)) for given logger.

Parameters:
  • className (str) – The logger name for which the filter level is to be set. Use name Default to change the default filter level.
  • level (int) – The filter level to be set.

Warning

setting Default log level higher than MAX_LOG_LEVEL provided during compilation will have no effect. Logs will not be printed because they are removed during compilation.

yade._log.setOutputStream((str)arg1, (bool)arg2) → None
Parameters:
  • streamName (str) – sets the output stream, special names cout, cerr, clog use the std::cout, std::cerr, std::clog counterpart (std::clog the is the default output stream). Every other name means that log will be written to a file with name provided in the argument.
  • reset (bool) – dictates whether all previously set output streams are to be removed. When set to false: the new output stream is set additionally to the current one.
yade._log.setUseColors((bool)arg1) → None

Turn on/off colors in log messages. By default is on. If logging to a file then it is better to be turned off.

yade._log.testAllLevels() → None

This function prints test messages on all log levels. Can be used to see how filtering works and to what streams the logs are written.

yade._log.testOnceLevels() → None

This function prints test messages on all log levels using LOG_ONCE_* macro family.

yade._log.testTimedLevels() → None

This function prints timed test messages on all log levels. In this test the log levels ∈ [0…2] are timed to print every 2 seconds, levels ∈ [3,4] every 1 second and levels ∈ [5,6] every 0.5 seconds. The loop lasts for 2.1 seconds. Can be used to see how timed filtering works and to what streams the logs are written.

yade._log.unsetLevel((str)arg1) → None
Parameters:className (str) – The logger name for which the filter level is to be unset, so that a Default will be used instead. Unsetting the Default level will change it to max level and print everything.