diff --git a/Headphones.py b/Headphones.py index 7f9139fe..65c7d8fc 100644 --- a/Headphones.py +++ b/Headphones.py @@ -41,6 +41,7 @@ def main(): # Set up and gather command line arguments parser = argparse.ArgumentParser(description='Music add-on for SABnzbd+') + parser.add_argument('-v', '--verbose', action='store_true', help='Increase console logging verbosity') parser.add_argument('-q', '--quiet', action='store_true', help='Turn off console logging') parser.add_argument('-d', '--daemon', action='store_true', help='Run as a daemon') parser.add_argument('-p', '--port', type=int, help='Force Headphones to run on a specified port') @@ -50,13 +51,15 @@ def main(): parser.add_argument('--pidfile', help='Create a pid file (only relevant when running as a daemon)') args = parser.parse_args() - - if args.quiet: - headphones.QUIET=True + + if args.verbose: + headphones.VERBOSE = 2 + elif args.quiet: + headphones.VERBOSE = 0 if args.daemon: headphones.DAEMON=True - headphones.QUIET=True + headphones.VERBOSE = 0 if args.pidfile : headphones.PIDFILE = args.pidfile diff --git a/headphones/__init__.py b/headphones/__init__.py index c2a50ece..60637241 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -22,7 +22,7 @@ SIGNAL = None SYS_ENCODING = None -QUIET = False +VERBOSE = 1 DAEMON = False PIDFILE= None @@ -173,7 +173,7 @@ def initialize(): with INIT_LOCK: - global __INITIALIZED__, FULL_PATH, PROG_DIR, QUIET, DAEMON, DATA_DIR, CONFIG_FILE, CFG, LOG_DIR, CACHE_DIR, \ + global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, DATA_DIR, CONFIG_FILE, CFG, LOG_DIR, CACHE_DIR, \ HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, LAUNCH_BROWSER, GIT_PATH, \ CURRENT_VERSION, LATEST_VERSION, MUSIC_DIR, DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, \ ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, \ @@ -280,11 +280,11 @@ def initialize(): try: os.makedirs(LOG_DIR) except OSError: - if not QUIET: + if VERBOSE: print 'Unable to create the log directory. Logging to screen only.' # Start the logger, silence console logging if we need to - logger.headphones_log.initLogger(quiet=QUIET) + logger.headphones_log.initLogger(verbose=VERBOSE) # Update some old config code: if FOLDER_FORMAT == '%artist/%album/%track': diff --git a/headphones/logger.py b/headphones/logger.py index 9df46990..97c435bc 100644 --- a/headphones/logger.py +++ b/headphones/logger.py @@ -20,7 +20,7 @@ class RotatingLogger(object): self.max_files = max_files - def initLogger(self, quiet=False): + def initLogger(self, verbose=1): l = logging.getLogger('headphones') l.setLevel(logging.DEBUG) @@ -35,13 +35,13 @@ class RotatingLogger(object): filehandler.setFormatter(fileformatter) l.addHandler(filehandler) - if not quiet: - + if verbose: consolehandler = logging.StreamHandler() - consolehandler.setLevel(logging.INFO) - + if verbose == 1: + consolehandler.setLevel(logging.INFO) + if verbose == 2: + consolehandler.setLevel(logging.DEBUG) consoleformatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(message)s', '%d-%b-%Y %H:%M:%S') - consolehandler.setFormatter(consoleformatter) l.addHandler(consolehandler)