-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathhyperthymesia.py
55 lines (37 loc) · 1.26 KB
/
hyperthymesia.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
45
46
47
48
49
50
51
52
53
54
55
from config import load_config
import logging
from logging import config, Handler
settings = load_config('config/settings.yaml')
# Logging, but with more syllables
class Hyperthymesia(object):
names = {
'debug': logging.DEBUG,
'info': logging.INFO,
'error': logging.ERROR,
'warning': logging.WARNING,
'critical': logging.CRITICAL
}
def __init__(self, *arguments, **keywords):
logging.config.dictConfig(settings.logging)
def __set_log_level(self, level):
self.logger = logging.getLogger(level)
try:
level = self.names[level.lower()]
except KeyError:
level = logging.WARNING
self.logger.setLevel(level)
def info(self, message):
self.__set_log_level('info')
self.logger.info(message)
def debug(self, message):
self.__set_log_level('debug')
self.logger.debug(message)
def warn(self, message):
self.__set_log_level('warn')
self.logger.warn(message, exc_info=True)
class ChatHandler(logging.Handler):
def __init__(self, cx):
logging.Handler.__init__(self)
self.cortex = cx
def emit(self, record):
self.brain.thalamus.send(record)