From 5c298520332077e6bd9b7a0cec7ae51d7a1bb25b Mon Sep 17 00:00:00 2001 From: shypike Date: Sat, 10 Oct 2015 12:10:08 +0200 Subject: [PATCH] Replace --no-api-log command line switch with the "special" option "api_logging". More elegant code and automatically persistent. --- SABnzbd.py | 5 +---- sabnzbd/__init__.py | 1 - sabnzbd/cfg.py | 1 + sabnzbd/interface.py | 4 ++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/SABnzbd.py b/SABnzbd.py index 4f9b7b0..d8ae233 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -276,7 +276,6 @@ def print_help(): print " with full data reconstruction" print " --https Port to use for HTTPS server" print " --log-all Log all article handling (for developers)" - print " --no-api-log Do not log API calls (for developers)" print " --console Force console logging for OSX app" print " --new Run a new instance of SABnzbd" print " --no_ipv6 Do not listen on IPv6 address [::1]" @@ -825,7 +824,7 @@ def commandline_handler(frozen=True): try: opts, args = getopt.getopt(info, "phdvncw:l:s:f:t:b:2:", ['pause', 'help', 'daemon', 'nobrowser', 'clean', 'logging=', - 'weblogging=', 'server=', 'templates', 'no_ipv6', 'no-api-log', + 'weblogging=', 'server=', 'templates', 'no_ipv6', 'template2', 'browser=', 'config-file=', 'force', 'version', 'https=', 'autorestarted', 'repair', 'repair-all', 'log-all', 'no-login', 'pid=', 'new', 'sessions', 'console', 'pidfile=', @@ -976,8 +975,6 @@ def main(): pause = True elif opt in ('--log-all',): sabnzbd.LOG_ALL = True - elif opt in ('--no-api-log'): - sabnzbd.API_LOG = False elif opt in ('--no-login',): no_login = True elif opt in ('--pid',): diff --git a/sabnzbd/__init__.py b/sabnzbd/__init__.py index 3a3d5aa..8c4fca7 100644 --- a/sabnzbd/__init__.py +++ b/sabnzbd/__init__.py @@ -124,7 +124,6 @@ WEBLOGFILE = None LOGHANDLER = None GUIHANDLER = None LOG_ALL = False -API_LOG = True AMBI_LOCALHOST = False WIN_SERVICE = None # Instance of our Win32 Service Class BROWSER_URL = None diff --git a/sabnzbd/cfg.py b/sabnzbd/cfg.py index b417b30..d11b869 100644 --- a/sabnzbd/cfg.py +++ b/sabnzbd/cfg.py @@ -194,6 +194,7 @@ fsys_type = OptionNumber('misc', 'fsys_type', 0, 0, 2) wait_for_dfolder = OptionBool('misc', 'wait_for_dfolder', False) warn_empty_nzb = OptionBool('misc', 'warn_empty_nzb', True) sanitize_safe = OptionBool('misc', 'sanitize_safe', False) +api_logging = OptionBool('misc', 'api_logging', True) cherryhost = OptionStr('misc', 'host', DEF_HOST) if sabnzbd.WIN32: diff --git a/sabnzbd/interface.py b/sabnzbd/interface.py index 5f0af08..7868ff3 100644 --- a/sabnzbd/interface.py +++ b/sabnzbd/interface.py @@ -425,7 +425,7 @@ class MainPage(object): def api(self, **kwargs): """ Handler for API over http, with explicit authentication parameters """ if not kwargs.get('tickleme') or not cfg.web_watchdog(): - if sabnzbd.API_LOG: + if cfg.api_logging(): logging.debug('API-call from %s [%s] %s', cherrypy.request.remote.ip, cherrypy.request.headers.get('User-Agent', '??'), kwargs) if kwargs.get('mode', '') not in ('version', 'auth'): @@ -1364,7 +1364,7 @@ SPECIAL_BOOL_LIST = \ 'no_ipv6', 'keep_awake', 'empty_postproc', 'web_watchdog', 'wait_for_dfolder', 'warn_empty_nzb', 'enable_bonjour', 'warn_dupl_jobs', 'enable_par_cleanup', - 'enable_https_verification' + 'enable_https_verification', 'api_logging' ) SPECIAL_VALUE_LIST = \ ('size_limit', 'folder_max_length', 'fsys_type', 'movie_rename_limit', 'nomedia_marker',