BrianLogger class

(Shortest import: from brian2 import BrianLogger)

class brian2.utils.logger.BrianLogger(name)[source]

Bases: object

Convenience object for logging. Call get_logger() to get an instance of this class.

Parameters:

name : str

The name used for logging, normally the name of the module.

Methods

debug(msg[, name_suffix, once]) Log a debug message.
error(msg[, name_suffix, once]) Log an error message.
info(msg[, name_suffix, once]) Log an info message.
log_level_debug() Set the log level to “debug”.
log_level_error() Set the log level to “error”.
log_level_info() Set the log level to “info”.
log_level_warn() Set the log level to “warn”.
suppress_hierarchy(name[, filter_log_file]) Suppress all log messages in a given hiearchy.
suppress_name(name[, filter_log_file]) Suppress all log messages with a given name.
warn(msg[, name_suffix, once]) Log a warn message.

Details

debug(msg, name_suffix=None, once=False)[source]

Log a debug message.

Parameters:

msg : str

The message to log.

name_suffix : str, optional

A suffix to add to the name, e.g. a class or function name.

once : bool, optional

Whether this message should be logged only once and not repeated if sent another time.

error(msg, name_suffix=None, once=False)[source]

Log an error message.

Parameters:

msg : str

The message to log.

name_suffix : str, optional

A suffix to add to the name, e.g. a class or function name.

once : bool, optional

Whether this message should be logged only once and not repeated if sent another time.

info(msg, name_suffix=None, once=False)[source]

Log an info message.

Parameters:

msg : str

The message to log.

name_suffix : str, optional

A suffix to add to the name, e.g. a class or function name.

once : bool, optional

Whether this message should be logged only once and not repeated if sent another time.

static log_level_debug()[source]

Set the log level to “debug”.

static log_level_error()[source]

Set the log level to “error”.

static log_level_info()[source]

Set the log level to “info”.

static log_level_warn()[source]

Set the log level to “warn”.

static suppress_hierarchy(name, filter_log_file=False)[source]

Suppress all log messages in a given hiearchy.

Parameters:

name : str

Suppress all log messages in the given name hierarchy. For example, specifying 'brian2' suppresses all messages logged by Brian, specifying 'brian2.codegen' suppresses all messages generated by the code generation modules.

filter_log_file : bool, optional

Whether to suppress the messages also in the log file. Defaults to False meaning that suppressed messages are not displayed on the console but are still saved to the log file.

static suppress_name(name, filter_log_file=False)[source]

Suppress all log messages with a given name.

Parameters:

name : str

Suppress all log messages ending in the given name. For example, specifying 'resolution_conflict' would suppress messages with names such as brian2.equations.codestrings.CodeString.resolution_conflict or brian2.equations.equations.Equations.resolution_conflict.

filter_log_file : bool, optional

Whether to suppress the messages also in the log file. Defaults to False meaning that suppressed messages are not displayed on the console but are still saved to the log file.

warn(msg, name_suffix=None, once=False)[source]

Log a warn message.

Parameters:

msg : str

The message to log.

name_suffix : str, optional

A suffix to add to the name, e.g. a class or function name.

once : bool, optional

Whether this message should be logged only once and not repeated if sent another time.

Tutorials and examples using this