peri.logger¶
A simple but pretty logging interface for configurable logs across all packages. To use, simply import the base log and (maybe) tack on a child context:
from peri.logger import log
clog = log.getChild("<child name>") # optional
The possible options are:
clog.{info,debug,warn,error,fatal}(...)
Call with:
log.info('something %r' % object)
log.error('bad thing')
You can set the level of information displayed, for example, to only display critical errors. The order is debug, info, warn, error, fatal
log.set_level('info')
-
class
peri.logger.
Logger
(verbosity=’vvv’, colorlogs=False, logtofile=False, logfilename=”)¶ Create a new logger class. Since the logging interface is actually global, any new logs will create even more clutter on the screen. Therefore, only create one! (as is created at the bottom of this file)
-
add_handler
(name=’console-color’, level=’info’, formatter=’standard’, **kwargs)¶ Add another handler to the logging system if not present already. Available handlers are currently: [‘console-bw’, ‘console-color’, ‘rotating-log’]
-
noformat
()¶ Temporarily do not use any formatter so that text printed is raw
-
remove_handler
(name)¶ Remove handler from the logging system if present already. Available handlers are currently: [‘console-bw’, ‘console-color’, ‘rotating-log’]
-
set_formatter
(formatter=’standard’, handlers=None)¶ Set the text format of messages to one of the pre-determined forms, one of [‘quiet’, ‘minimal’, ‘standard’, ‘verbose’]
-
set_level
(level=’info’, handlers=None)¶ Set the logging level (which types of logs are actually printed / recorded) to one of [‘debug’, ‘info’, ‘warn’, ‘error’, ‘fatal’] in that order of severity
-
set_verbosity
(verbosity=’vvv’, handlers=None)¶ Set the verbosity level of a certain log handler or of all handlers.
Parameters: - verbosity ('v' to 'vvvvv') – the level of verbosity, more v’s is more verbose
- handlers (string, or list of strings) –
handler names can be found in
peri.logger.types.keys()
Current set is:['console-bw', 'console-color', 'rotating-log']
-