-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_logger.py
More file actions
32 lines (26 loc) · 1.07 KB
/
system_logger.py
File metadata and controls
32 lines (26 loc) · 1.07 KB
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
"""Logger to log into system logger"""
import logging
from QLog.log_entry import LogEntry
from QLog.log_level import LogLevel
from QLog.logger import Logger
class SystemLogger(Logger):
"""Logger to log into system logger"""
def __init__(self, log_level=LogLevel.INFO):
self.log_level = log_level
if self.log_level is LogLevel.INFO:
logging.getLogger().setLevel(logging.INFO)
elif self.log_level is LogLevel.WARNING:
logging.getLogger().setLevel(logging.WARNING)
elif self.log_level is LogLevel.ERROR:
logging.getLogger().setLevel(logging.ERROR)
else:
logging.getLogger().setLevel(logging.DEBUG)
def do_log(self, log_entry: LogEntry):
text = log_entry.meta_text + log_entry.text
if log_entry.log_level is LogLevel.INFO:
return logging.info(text)
if log_entry.log_level is LogLevel.WARNING:
return logging.warning(text)
if log_entry.log_level is LogLevel.ERROR:
return logging.error(text)
return logging.debug(text)