cashocs.log.Logger#
- class cashocs.log.Logger(
- name: str,
Bases:
objectBase class for logging.
Initializes the logger.
- Parameters:
name (str) – The name of the logger.
Methods Summary
add_handler(handler)Adds an additional handler to the logger.
add_logfile(filename[, mode, level])Adds a file handler to the logger.
This function adds a time stamp to the logged events.
begin(message[, level])This signals the beginning of a (timed) block of logs.
critical(message)Issues a message at the critical level.
debug(message)Issues a message at the debug level.
end()This signals the end of a block started with
cashocs.log.begin().error(message)Issues a message at the error level.
info(message)Issues a message at the info level.
log(level, message)Use the logging functionality of the logger to log to (various) handlers.
This method removes the time stamp from the logged events.
set_comm(comm)Sets the MPI communicator used for logging.
set_log_level(level)This method sets the log level of the default handler, i.e., the console.
trace(message)Issues a message at the trace level.
warning(message)Issues a message at the warning level.
Methods Documentation
- add_handler(
- handler: Handler,
Adds an additional handler to the logger.
- Parameters:
handler (logging.Handler) – The handler that should be added to the logger.
- Return type:
None
- add_logfile(
- filename: str,
- mode: str = 'a',
- level: int = 10,
Adds a file handler to the logger.
- Parameters:
filename (str) – The path to the file which is used for logging.
mode (str, optional) – The mode with which the log file should be treated. “a” appends to the file and “w” overwrites the file. Defaults to “a”.
level (int, optional) – The log level used for logging to the file. Defaults to logging.DEBUG.
- Returns:
The file handler for the log file.
- Return type:
FileHandler
- add_timestamps() None[source]#
This function adds a time stamp to the logged events.
- Return type:
None
- begin(
- message: str,
- level: int = 20,
This signals the beginning of a (timed) block of logs.
This is closed with a suitable call to
cashocs.log.end()with which each call tocashocs.log.begin()has to be accompanied by.- Parameters:
message (str) – The message indicating what block is started.
level (int, optional) – The log level used for issuing the messages. Defaults to logging.INFO.
- Return type:
None
- critical(
- message: str,
Issues a message at the critical level.
Note that this does not raise an exception at the moment.
- Parameters:
message (str) – The message that should be logged.
- Return type:
None
- debug(
- message: str,
Issues a message at the debug level.
- Parameters:
message (str) – The message that should be logged.
- Return type:
None
- end() None[source]#
This signals the end of a block started with
cashocs.log.begin().- Return type:
None
- error(
- message: str,
Issues a message at the error level.
Note that this does not raise an exception at the moment.
- Parameters:
message (str) – The message that should be logged.
- Return type:
None
- info(
- message: str,
Issues a message at the info level.
- Parameters:
message (str) – The message that should be logged.
- Return type:
None
- log(
- level: int,
- message: str,
Use the logging functionality of the logger to log to (various) handlers.
- Parameters:
level (int) – The log level of the message, same as the ones used in the python logging module.
message (str) – The message that should be logged.
- Return type:
None
- remove_timestamps() None[source]#
This method removes the time stamp from the logged events.
- Return type:
None
- set_comm(
- comm: MPI.Comm,
Sets the MPI communicator used for logging.
This should be the same that is supplied for the mesh generation, otherwise the program could hang indefinitely.
- Parameters:
comm (MPI.Comm) – The MPI communicator for logging.
- Return type:
None
- set_log_level(
- level: int,
This method sets the log level of the default handler, i.e., the console.
- Parameters:
level (int) – The log level that should be used for the default handler.
- Return type:
None