Fix for debug logging

pull/249/head
Halali 6 years ago
parent 4d007bb279
commit a025ae40de

@ -1,19 +1,12 @@
import os
import sys
import logging
import re
from logging.handlers import TimedRotatingFileHandler
from get_argv import config_dir
from get_settings import get_general_settings
logger = logging.getLogger()
debug = get_general_settings()[4]
if debug is False:
log_level = "INFO"
else:
log_level = "DEBUG"
class OneLineExceptionFormatter(logging.Formatter):
def formatException(self, exc_info):
@ -39,7 +32,12 @@ class NoExceptionFormatter(logging.Formatter):
return ''
def configure_logging():
def configure_logging(debug=False):
if not debug:
log_level = "INFO"
else:
log_level = "DEBUG"
logger.handlers = []
logger.setLevel(log_level)
@ -54,7 +52,7 @@ def configure_logging():
# ch.addFilter(MyFilter())
logger.addHandler(ch)
#File Logging
# File Logging
global fh
fh = TimedRotatingFileHandler(os.path.join(config_dir, 'log/bazarr.log'), when="midnight", interval=1,
backupCount=7)
@ -64,7 +62,7 @@ def configure_logging():
fh.addFilter(BlacklistFilter())
fh.addFilter(PublicIPFilter())
if debug is True:
if debug:
logging.getLogger("apscheduler").setLevel(logging.DEBUG)
logging.getLogger("subliminal").setLevel(logging.DEBUG)
logging.getLogger("git").setLevel(logging.DEBUG)
@ -145,13 +143,3 @@ class PublicIPFilter(logging.Filter):
def empty_log():
fh.doRollover()
def update_settings(debug):
if debug == 'False':
level = "INFO"
else:
level = "DEBUG"
logger.setLevel(level)
for handler in logger.handlers:
handler.setLevel(level)

@ -23,8 +23,9 @@ update_notifier()
from get_settings import get_general_settings, get_proxy_settings
import logging
from logger import configure_logging, empty_log, update_settings
configure_logging()
from logger import configure_logging, empty_log
configure_logging(get_general_settings()[4])
import requests
if get_proxy_settings()[0] != 'None':
@ -1129,8 +1130,6 @@ def save_settings():
cfg.set('general', 'use_embedded_subs', text_type(settings_general_embedded))
cfg.set('general', 'only_monitored', text_type(settings_general_only_monitored))
cfg.set('general', 'adaptive_searching', text_type(settings_general_adaptive_searching))
update_settings(settings_general_debug)
if after != before:
configured()
@ -1301,6 +1300,8 @@ def save_settings():
with open(config_file, 'wb') as f:
cfg.write(f)
configure_logging(get_general_settings()[4])
notifiers = c.execute("SELECT * FROM table_settings_notifier ORDER BY name").fetchall()
for notifier in notifiers:
enabled = request.forms.get('settings_notifier_' + notifier[0] + '_enabled')

Loading…
Cancel
Save