From 80f8fa4e5ef9a1a3050d371ec0c9e52e7b0a39eb Mon Sep 17 00:00:00 2001 From: Josh Walawender Date: Fri, 29 May 2020 15:46:33 -1000 Subject: [PATCH] Create logger appears not to be needed. --- soundplay.py | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/soundplay.py b/soundplay.py index 4b58dd6..ec05705 100644 --- a/soundplay.py +++ b/soundplay.py @@ -8,6 +8,7 @@ import platform log = logging.getLogger('KRO') +log.setLevel(logging.DEBUG) class soundplay(object): @@ -127,48 +128,6 @@ def full_path(player=None): return sound_path - -##------------------------------------------------------------------------- -## Create logger -##------------------------------------------------------------------------- -def create_logger(): - - ## Create logger object - log = logging.getLogger('KRO') - - ## Only add handlers if none already exist (eliminates duplicate lines) - if len(log.handlers) > 0: - return - - #create log file and log dir if not exist - ymd = datetime.utcnow().strftime('%Y%m%d') - try: - Path('logs/').mkdir(parents=True, exist_ok=True) - except PermissionError as error: - print(str(error)) - print(f"ERROR: Unable to create logger at {logFile}") - print("Make sure you have write access to this directory.\n") - log.info("EXITING APP\n") - sys.exit(1) - - #stream/console handler (info+ only) - logConsoleHandler = logging.StreamHandler() - logConsoleHandler.setLevel(logging.INFO) - logFormat = logging.Formatter(' %(levelname)8s: %(message)s') - logFormat.converter = time.gmtime - logConsoleHandler.setFormatter(logFormat) - log.addHandler(logConsoleHandler) - - #file handler (full debug logging) - logFile = f'logs/keck-remote-log-utc-{ymd}.txt' - logFileHandler = logging.FileHandler(logFile) - logFileHandler.setLevel(logging.DEBUG) - logFormat = logging.Formatter('%(asctime)s UT - %(levelname)s: %(message)s') - logFormat.converter = time.gmtime - logFileHandler.setFormatter(logFormat) - log.addHandler(logFileHandler) - - ##------------------------------------------------------------------------- ## main ##-------------------------------------------------------------------------