-
Notifications
You must be signed in to change notification settings - Fork 4
/
talkshowLogger.py
38 lines (27 loc) · 987 Bytes
/
talkshowLogger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
'''
Created on 20 May 2013
@author: Joé Schaul
'''
import logging
# create logger
logger = logging.getLogger('talkshow')
logger.setLevel(logging.DEBUG)
# create file handler which logs even debug messages
fileDebugLogger = logging.FileHandler('debug.log')
fileDebugLogger.setLevel(logging.DEBUG)
# create file handler which logs warn messages
fileWarnLogger = logging.FileHandler('warn.log')
fileWarnLogger.setLevel(logging.WARN)
# create console handler
consoleLogger = logging.StreamHandler()
consoleLogger.setLevel(logging.DEBUG)
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(module)s:%(lineno)s %(funcName)s - %(message)s')
fileDebugLogger.setFormatter(formatter)
consoleLogger.setFormatter(formatter)
fileWarnLogger.setFormatter(formatter)
# add the handlers to the logger
logger.addHandler(fileDebugLogger)
logger.addHandler(consoleLogger)
logger.addHandler(fileWarnLogger)