-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestLogger.py
More file actions
executable file
·29 lines (24 loc) · 747 Bytes
/
testLogger.py
File metadata and controls
executable file
·29 lines (24 loc) · 747 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import logging.config
import logging_config
from logging_config import RotatingFileNameHandler
# set logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL
LEVEL = "ERROR"
LOGGING = logging_config.LOGGING
LOGGING["root"]["level"] = LOGGING["handlers"]["default"]["level"] = LEVEL
logging.config.dictConfig(logging_config.LOGGING)
# create logger
logger = logging.getLogger()
logger.addHandler(RotatingFileNameHandler(__file__, "./log"))
# "application" code
logger.debug("debug message")
logger.info("info message")
logger.warn("warn message")
logger.error("error message")
logger.critical("critical message")
try:
print( "AAAAA" + 1+90 )
except Exception, e:
logger.error(e)