multiml.logger module
Logger module.
In principle, modules in multiml library use this logger. There are some print levels: DEBUG
,
INFO
, WARN
, ERROR
and DISABLED
.
Examples
>>> from multiml import logger
>>> logger.set_level(logger.INFO) # Set to DEBUG
>>> logger.debug("This message is not printed at INFO level.")
- multiml.logger.convert(level)
convert str to int.
- multiml.logger.set_level(level)
Set log level.
- multiml.logger.get_now()
Get current time with
%Y-%m-%d %H:%M:%S
formant.- Returns:
the current timestamp.
- Return type:
str
- multiml.logger.debug(msg, *args)
Show debug [D] message.
- multiml.logger.info(msg, *args)
Show information [I] message.
- multiml.logger.warn(msg, *args)
Show warning [W] message.
- multiml.logger.error(msg, *args)
Show error [E] message.
- multiml.logger.counter(count, max_counts, divide=1, message=None)
Show process counter as information.
>>> '({count}/{max_counts}) events processed (message)'
- multiml.logger.header1(message, level=<function info>)
Show the following header.
>>> '=================================' >>> '============ message ============' >>> '================================='
- multiml.logger.header2(message, level=<function info>)
Show the following header.
>>> '------------ message ------------'
- multiml.logger.header3(message, level=<function info>)
Show the following header.
>>> ============ message ============
- multiml.logger.table(names, data, header=None, footer=None, max_length=30)
Show table. All data must be str.
>>> names = ['var0', 'var1'] >>> data = [['hoge0', 'hoge1'], ['hoge2', 'hoge3']] >>> header = 'header message' >>> footer = 'footer message' >>> >>> '==============' >>> 'header message' >>> '==============' >>> 'var0 var1' >>> '--------------' >>> 'hoge0 hoge1' >>> 'hoge2 hoge3' >>> '--------------' >>> 'footer message' >>> '=============='
- multiml.logger.logging(func)
Show the header and footer indicating start and end algorithm.
Examples
>>> from multiml import logger >>> >>> @logger.logging >>> def your_func(arg0, arg1): >>> pass