Skip to content

Commit

Permalink
Create logger appears not to be needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwalawender committed May 30, 2020
1 parent 89562f6 commit 80f8fa4
Showing 1 changed file with 1 addition and 42 deletions.
43 changes: 1 addition & 42 deletions soundplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import platform

log = logging.getLogger('KRO')
log.setLevel(logging.DEBUG)


class soundplay(object):
Expand Down Expand Up @@ -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
##-------------------------------------------------------------------------
Expand Down

0 comments on commit 80f8fa4

Please sign in to comment.