Make verbose logging an advanced config option (Fixes Tautulli/Tautulli-Issues#205)

* Verbose logging is enabled by default
* Make toggleVerbose stick
This commit is contained in:
JonnyWong16 2020-01-20 20:49:37 -08:00
parent e90390be67
commit b9d5e49a71
4 changed files with 12 additions and 5 deletions

View file

@ -106,8 +106,8 @@ def main():
plexpy.QUIET = True plexpy.QUIET = True
# Do an intial setup of the logger. # Do an intial setup of the logger.
logger.initLogger(console=not plexpy.QUIET, log_dir=False, # Require verbose for pre-initilization to see critical errors
verbose=plexpy.VERBOSE) logger.initLogger(console=not plexpy.QUIET, log_dir=False, verbose=True)
try: try:
plexpy.SYS_TIMEZONE = tzlocal.get_localzone() plexpy.SYS_TIMEZONE = tzlocal.get_localzone()

View file

@ -65,7 +65,7 @@ SYS_LANGUAGE = None
SYS_ENCODING = None SYS_ENCODING = None
QUIET = False QUIET = False
VERBOSE = True VERBOSE = False
DAEMON = False DAEMON = False
CREATEPID = False CREATEPID = False
PIDFILE = None PIDFILE = None
@ -122,6 +122,7 @@ def initialize(config_file):
global CONFIG global CONFIG
global CONFIG_FILE global CONFIG_FILE
global VERBOSE
global _INITIALIZED global _INITIALIZED
global CURRENT_VERSION global CURRENT_VERSION
global LATEST_VERSION global LATEST_VERSION
@ -152,6 +153,8 @@ def initialize(config_file):
if not log_writable and not QUIET: if not log_writable and not QUIET:
sys.stderr.write("Unable to create the log directory. Logging to screen only.\n") sys.stderr.write("Unable to create the log directory. Logging to screen only.\n")
VERBOSE = VERBOSE or bool(CONFIG.VERBOSE_LOGS)
# Start the logger, disable console if needed # Start the logger, disable console if needed
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR if log_writable else None, logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR if log_writable else None,
verbose=VERBOSE) verbose=VERBOSE)

View file

@ -603,6 +603,7 @@ _CONFIG_DEFINITIONS = {
'UPDATE_LABELS': (int, 'General', 1), 'UPDATE_LABELS': (int, 'General', 1),
'UPDATE_LIBRARIES_DB_NOTIFY': (int, 'General', 1), 'UPDATE_LIBRARIES_DB_NOTIFY': (int, 'General', 1),
'UPDATE_NOTIFIERS_DB': (int, 'General', 1), 'UPDATE_NOTIFIERS_DB': (int, 'General', 1),
'VERBOSE_LOGS': (int, 'Advanced', 1),
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1), 'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1), 'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1),
'WEBSOCKET_MONITOR_PING_PONG': (int, 'Advanced', 0), 'WEBSOCKET_MONITOR_PING_PONG': (int, 'Advanced', 0),

View file

@ -2667,8 +2667,11 @@ class WebInterface(object):
@requireAuth(member_of("admin")) @requireAuth(member_of("admin"))
def toggleVerbose(self, **kwargs): def toggleVerbose(self, **kwargs):
plexpy.VERBOSE = not plexpy.VERBOSE plexpy.VERBOSE = not plexpy.VERBOSE
logger.initLogger(console=not plexpy.QUIET,
log_dir=plexpy.CONFIG.LOG_DIR, verbose=plexpy.VERBOSE) plexpy.CONFIG.__setattr__('VERBOSE_LOGS', plexpy.VERBOSE)
plexpy.CONFIG.write()
logger.initLogger(console=not plexpy.QUIET, log_dir=plexpy.CONFIG.LOG_DIR, verbose=plexpy.VERBOSE)
logger.info(u"Verbose toggled, set to %s", plexpy.VERBOSE) logger.info(u"Verbose toggled, set to %s", plexpy.VERBOSE)
logger.debug(u"If you read this message, debug logging is available") logger.debug(u"If you read this message, debug logging is available")
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "logs") raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "logs")