-
Notifications
You must be signed in to change notification settings - Fork 35
/
logger.py
45 lines (25 loc) · 970 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
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
__author__ = 'Chariton Karamitas <[email protected]>'
import logging
_ROOT_LOGGER_NAME = 'exploit'
_ROOT_LOGGER = None
def get_root_logger():
global _ROOT_LOGGER
if _ROOT_LOGGER is None:
_ROOT_LOGGER = logging.getLogger(_ROOT_LOGGER_NAME)
_ROOT_LOGGER.setLevel(logging.DEBUG)
formatter = logging.Formatter(fmt='(%(asctime)s) [*] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
handler = logging.FileHandler('%s.log' % _ROOT_LOGGER_NAME)
handler.setLevel(logging.DEBUG)
handler.setFormatter(formatter)
_ROOT_LOGGER.addHandler(handler)
handler = logging.StreamHandler()
handler.setLevel(logging.DEBUG)
handler.setFormatter(formatter)
_ROOT_LOGGER.addHandler(handler)
return _ROOT_LOGGER
def get_logger(name):
return logging.getLogger('%s.%s' % (get_root_logger().name, name))
def shutdown():
logging.shutdown()