logalpha.logger




class Logger[source]

Base logging interface.

By default the levels and colors are the conventional set. Append any number of appropriate handlers.

Example:
>>> log = Logger()
>>> log.warning('foo')
>>> Logger.handlers.append(StreamHandler())
>>> log.warning('bar')
bar

levels = [Level(name='DEBUG', value=0), Level(name='INFO', value=1), Level(name='WARNING', value=2), Level(name='ERROR', value=3), Level(name='CRITICAL', value=4)]
colors = [Color(name='blue', foreground='\x1b[34m', background='\x1b[44m'), Color(name='green', foreground='\x1b[32m', background='\x1b[42m'), Color(name='yellow', foreground='\x1b[33m', background='\x1b[43m'), Color(name='red', foreground='\x1b[31m', background='\x1b[41m'), Color(name='magenta', foreground='\x1b[35m', background='\x1b[45m')]

write(level: logalpha.level.Level, content: Any) → None[source]

Publish message to all handlers if its level is sufficient for that handler.

Note

It’s expected that the logger will be called with one of the dynamically instrumented level methods (e.g., info()), and not call the write() method directly.