diff --git a/liveMonitor.py b/liveMonitor.py index 08a66bb..a59e9d7 100644 --- a/liveMonitor.py +++ b/liveMonitor.py @@ -12,7 +12,7 @@ from ukmonPostProc import setupLogging -log = logging.getLogger() +log = logging.getLogger("ukmonlogger") timetowait = 30 # seconds to wait for a new line before deciding the log is stale diff --git a/sendToLive.py b/sendToLive.py index 4eb720e..72c0d8b 100644 --- a/sendToLive.py +++ b/sendToLive.py @@ -18,7 +18,7 @@ from RMS.Formats.FieldIntensities import readFieldIntensitiesBin -log = logging.getLogger("logger") +log = logging.getLogger("ukmonlogger") def getBlockBrightness(dirpath, filename): diff --git a/ukmonInstaller.py b/ukmonInstaller.py index 19fe450..5fac352 100644 --- a/ukmonInstaller.py +++ b/ukmonInstaller.py @@ -20,7 +20,7 @@ from RMS.Misc import isRaspberryPi from uploadToArchive import readIniFile -log = logging.getLogger() +log = logging.getLogger("ukmonlogger") log.setLevel(logging.WARNING) oldip = '3.9.65.98' diff --git a/ukmonPostProc.py b/ukmonPostProc.py index 6d67455..094d96f 100644 --- a/ukmonPostProc.py +++ b/ukmonPostProc.py @@ -23,7 +23,7 @@ from uploadToArchive import uploadToArchive, readIniFile -log = logging.getLogger() +log = logging.getLogger("ukmonlogger") log.setLevel(logging.INFO) @@ -31,6 +31,9 @@ def setupLogging(logpath, prefix): print('about to initialise logger') logdir = os.path.expanduser(logpath) os.makedirs(logdir, exist_ok=True) + log.info('removing any existing log handlers') + for handler in log.handlers[:]: + log.removeHandler(handler) logfilename = os.path.join(logdir, prefix + datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%d_%H%M%S.%f') + '.log') handler = logging.handlers.TimedRotatingFileHandler(logfilename, when='D', interval=1) diff --git a/uploadToArchive.py b/uploadToArchive.py index b26209b..8da3bda 100644 --- a/uploadToArchive.py +++ b/uploadToArchive.py @@ -25,12 +25,12 @@ import tempfile from RMS.Formats.FTPdetectinfo import readFTPdetectinfo -log = logging.getLogger("logger") +log = logging.getLogger("ukmonlogger") def readKeyFile(filename, inifvals): if not os.path.isfile(filename): - log.error('Config file missing, cannot continue') + log.error('Keyfile {} not downloaded. Check ssh key and station location with ukmon team.'.format(filename)) return False with open(filename, 'r') as fin: lis = fin.readlines() @@ -90,7 +90,7 @@ def getAWSKey(inifvals): handle, tmpfnam = tempfile.mkstemp() ftp_client.get(inifvals['LOCATION']+'.csv', tmpfnam) except Exception as e: - log.error('unable to find AWS key') + log.error('unable to find AWS key, check location in ukmon.ini') log.info(e, exc_info=True) ftp_client.close() try: @@ -99,7 +99,7 @@ def getAWSKey(inifvals): os.remove(tmpfnam) key, sec = lis[1].split(',') except Exception as e: - log.error('malformed AWS key') + log.error('malformed AWS key, contact support') log.info(e, exc_info=True) except Exception as e: log.error('unable to retrieve AWS key') @@ -114,7 +114,7 @@ def getAWSKey(inifvals): def readIniFile(filename): if not os.path.isfile(filename): - log.error('ukmon.ini missing, cannot continue') + log.error('{} missing, cannot continue'.format(filename)) return False with open(filename, 'r') as fin: lis = fin.readlines()