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.
Attributes
_log_messages
Class attribute for remembering log messages that should only be displayed once exception_occured
Class attribute to remember whether any exception occured file_handler
The logging.FileHandler
responsible for logging to the temporary log filetmp_log
The name of the temporary log file (by default deleted after the run if no exception occurred), if any tmp_script
The name of the temporary copy of the main script file (by default deleted after the run if no exception occurred), if any Methods
debug
(msg[, name_suffix, once])Log a debug message. diagnostic
(msg[, name_suffix, once])Log a diagnostic message. error
(msg[, name_suffix, once])Log an error message. info
(msg[, name_suffix, once])Log an info message. initialize
()Initialize Brian’s logging system. log_level_debug
()Set the log level to “debug”. log_level_diagnostic
()Set the log level to “diagnostic”. 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
-
_log_messages
¶ Class attribute for remembering log messages that should only be displayed once
-
exception_occured
¶ Class attribute to remember whether any exception occured
-
file_handler
¶ The
logging.FileHandler
responsible for logging to the temporary log file
-
tmp_log
¶ The name of the temporary log file (by default deleted after the run if no exception occurred), if any
-
tmp_script
¶ The name of the temporary copy of the main script file (by default deleted after the run if no exception occurred), if any
-
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.
-
diagnostic
(msg, name_suffix=None, once=False)[source]¶ Log a diagnostic 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
initialize
()[source]¶ Initialize Brian’s logging system. This function will be called automatically when Brian is imported.
-
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 asbrian2.equations.codestrings.CodeString.resolution_conflict
orbrian2.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¶
- Example frompapers/Rossant_et_al_2011bis