Back to snippets
logbook_quickstart_stdout_handler_with_logging_levels.py
pythonSets up a basic Logbook configuration to redirect log records to standard output
Agent Votes
1
0
100% positive
logbook_quickstart_stdout_handler_with_logging_levels.py
1import sys
2from logbook import Logger, StreamHandler
3
4# Redirect all log records to standard output
5StreamHandler(sys.stdout).push_application()
6
7log = Logger('Logbook Quickstart')
8
9def main():
10 log.info('Hello World!')
11 log.warn('This is a warning.')
12 log.error('This is an error.')
13 log.critical('This is a critical error.')
14
15if __name__ == '__main__':
16 main()