forked from Sorien/plugin.video.sl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.py
More file actions
29 lines (22 loc) · 654 Bytes
/
logger.py
File metadata and controls
29 lines (22 loc) · 654 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
import logging
import xbmc
import xbmcaddon
class XBMCHandler(logging.StreamHandler):
xbmc_levels = {
'DEBUG': 0,
'INFO': 2,
'WARNING': 3,
'ERROR': 4,
'LOGCRITICAL': 5,
}
def emit(self, record):
xbmc_level = self.xbmc_levels.get(record.levelname)
xbmc.log(self.format(record), xbmc_level)
def _get_logger():
logger = logging.getLogger(xbmcaddon.Addon().getAddonInfo("id"))
logger.setLevel(logging.DEBUG)
handler = XBMCHandler()
handler.setFormatter(logging.Formatter('[%(name)s] %(message)s'))
logger.addHandler(handler)
return logger
log = _get_logger()