Log module¶
Provide log related functions. You need to Initialize the logger and use the logger to make logs.
Example:
>>> logger = Initialize()
Use logger.level(*msg) to log like:
>>> logger.error("Pickle data writing Failed.")
>>> logger.info("Pickle data of ", foo, " written successfully.")
The log will be stored into LogFile.log by default.
-
Log.
Initialize
(FileName='LogFile.log', LogLevel='INFO', WriteToStream=False)[source]¶ Initialize loggers for logging. A logger will be returned.
Parameters: - FileName (String) – Path of the log file
- LogLevel (String) – LogLevel of the logger, which can be “DEBUG”, “INFO”, “ERROR”
- WriteToStream (Boolean) – Whether to write to stdout
Returns: logger: The logger used for logging
Return type: logging.loggger
-
class
Log.
Logger
(name, level=0)[source]¶ Bases:
logging.Logger
-
critical
(*args, **kwargs)[source]¶ Log ‘msg % args’ with severity ‘CRITICAL’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.critical(“Houston, we have a %s”, “major disaster”, exc_info=1)
-
debug
(*args, **kwargs)[source]¶ Log ‘msg % args’ with severity ‘DEBUG’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.debug(“Houston, we have a %s”, “thorny problem”, exc_info=1)
-
error
(*args, **kwargs)[source]¶ Log ‘msg % args’ with severity ‘ERROR’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.error(“Houston, we have a %s”, “major problem”, exc_info=1)
-
exception
(*args, exc_info=True, **kwargs)[source]¶ Convenience method for logging an ERROR with exception information.
-
info
(*args, **kwargs)[source]¶ Log ‘msg % args’ with severity ‘INFO’.
To pass exception information, use the keyword argument exc_info with a true value, e.g.
logger.info(“Houston, we have a %s”, “interesting problem”, exc_info=1)
-