forked from fireeye/HXTool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhxtool_logging.py
More file actions
34 lines (23 loc) · 753 Bytes
/
hxtool_logging.py
File metadata and controls
34 lines (23 loc) · 753 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import threading
import logging
from multiprocessing import Queue, RLock
root_logger_name = "hxtool"
def setLoggerClass():
logging.setLoggerClass(hxtool_logger)
def getLoggerName(name):
return "{}.{}".format(root_logger_name, name)
def getLogger(name = None):
_name = root_logger_name
if name is not None:
_name = getLoggerName(name)
return logging.getLogger(_name)
class hxtool_logger(logging.Logger):
def __init__(self, name, level=logging.NOTSET):
super(hxtool_logger, self).__init__(name, level=level)
def callHandlers(self, record):
with RLock():
_thread = threading.Thread(target=super(hxtool_logger, self).callHandlers(record))
_thread.start()
_thread.join()