pypeec.log
- Module for handling the logging.
Use a global timer to measure the elapsed time.
Provide a class for timing (and logging) code blocks.
Measure duration with local timers.
Log exceptions.
- class pypeec.log.BlockTimer(logger, name)
- Class for timing a block of code.
Uses enter and exit magic methods.
Display the results with a logger.
- Parameters:
logger (logger) – Logger object instance.
name (string) – Name of the code block.
- class pypeec.log.BlockIndent
- Class for indenting a block of code.
Uses enter and exit magic methods.
Display the results with a logger.
- pypeec.log.log_exception(logger, ex)
- Log an exception.
Log the exception type, message, and trace.
Remove the context from the exception before the logging.
- Parameters:
logger (logger) – Logger object instance.
ex (exception) – Exception to be logged.
- pypeec.log.get_timer()
Get a timestamp with the current time.
- Returns:
timestamp – Timestamp with the current time.
- Return type:
timestamp
- pypeec.log.get_duration(timestamp)
Get the elapsed time with respect to a timestamp.
- Parameters:
timestamp (timestamp) – Timestamp with the reference time.
- Returns:
duration (duration) – Duration object with the elapsed time.
fmt (string) – String with the formatted elapsed time.
- pypeec.log.get_logger(name)
Get a logger with a specified name.
- Parameters:
name (string) – Name of the logger to be returned. If the logger does not exist, the logger is created. If the logger does exist, the logger is returned.
- Returns:
logger – Logger object instance.
- Return type:
logger