Trying to weed out dual logging.

This commit is contained in:
Anton Hvornum 2020-03-16 20:49:15 +01:00
parent 0e8bbb946d
commit e0f1e1b5fd
1 changed files with 43 additions and 34 deletions

View File

@ -26,6 +26,16 @@ worker_history = oDict()
instructions = oDict() instructions = oDict()
args = {} args = {}
create_log = True
try:
if 'log' in __builtins__.__dict__:
create_log = False
except:
if 'log' in __builtins__:
create_log = False
if create_log:
import logging import logging
from systemd.journal import JournalHandler from systemd.journal import JournalHandler
@ -49,7 +59,6 @@ class LOG_LEVELS:
DEBUG = 5 DEBUG = 5
LOG_LEVEL = 4 LOG_LEVEL = 4
def log(*msg, origin='UNKNOWN', level=5, **kwargs): def log(*msg, origin='UNKNOWN', level=5, **kwargs):
if level <= LOG_LEVEL: if level <= LOG_LEVEL:
msg = [item.decode('UTF-8', errors='backslashreplace') if type(item) == bytes else item for item in msg] msg = [item.decode('UTF-8', errors='backslashreplace') if type(item) == bytes else item for item in msg]