-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.py
31 lines (21 loc) · 878 Bytes
/
logger.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
import logging
def get_logger():
return logging
def config_logger():
formatString = '[%(levelname)s] - %(asctime)s - %(funcName)s - %(message)s'
formatter = logging.Formatter(formatString)
# Configure logging
logging.basicConfig(level=logging.INFO,
format=formatString)
# Create a file handler - DEBUG
file_handler = logging.FileHandler(filename='conversion.log')
file_handler.setLevel(logging.DEBUG)
# Create a console handler - INFO
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
# Create a formatter and set it for the handlers
file_handler.setFormatter(formatter)
console_handler.setFormatter(formatter)
# Add the handlers to the root logger
logging.getLogger('').addHandler(file_handler)
logging.getLogger('').addHandler(console_handler)