-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.py
More file actions
49 lines (32 loc) · 828 Bytes
/
a.py
File metadata and controls
49 lines (32 loc) · 828 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# vim: set expandtab ts=4 sw=4 filetype=python fileencoding=utf8:
import logging
import logging.config
import sys
import clepylogconfig
log = logging.getLogger("clepy")
def f():
return g()
def g():
return h()
def h():
1/0
def log_uncaught_exceptions(ex_cls, ex, tb):
log.critical(''.join(traceback.format_tb(tb)))
log.critical('{0}: {1}'.format(ex_cls, ex))
if __name__ == "__main__":
# THIS IS WHERE THE CONFIGURATION HAPPENS!
logging.config.dictConfig(clepylogconfig.LOGGING)
# This line logs uncaught exceptions. Remind me to talk about this
# later.
sys.excepthook = log_uncaught_exceptions
log.debug("DEBUG!")
log.info("INFO!")
log.warn("WARN!")
log.error("ERROR!")
log.critical("CRITICAL!")
try:
f()
except Exception as ex:
log.exception("OH NOES")
1/0
log.info("All done!")