diff --git a/Script/CastorScript.py b/Script/CastorScript.py index e90608259900d528597189517973881be9584e40..0fe309ad6e2fb2a8dd40dd056047e21abc23ac00 100755 --- a/Script/CastorScript.py +++ b/Script/CastorScript.py @@ -93,22 +93,13 @@ def main(conf): ##### Setup Environment for ERS ##### # check if there is a partition to log to - import ers - from ispy import IPCPartition - if IPCPartition(conf.partition).isValid(): - logInfo = {'file':logger.findCaller()[0],'line':logger.findCaller()[1]} - logger.debug("CastorScript found partition '%s'" % conf.partition,extra=logInfo) - else: - logInfo = {'file':logger.findCaller()[0],'line':logger.findCaller()[1]} - logger.error("CastorScript could not find partition '%s', not logging to mrs" - % conf.partition, extra=logInfo) + ##### Setup ERS ##### - #only if there is a partition, try to add ers backend - if IPCPartition(conf.partition).isValid(): + if conf.ERS_enabled: try: - #exceptions do not get caught when ers is imported after ispy - #import ers + import ers + from ispy import IPCPartition #ers.addLoggingHandler("main") ERS_handler=ers.LoggingHandler() set_log_level(conf.ERSLogLevel,ERS_handler) diff --git a/Script/Conf.cfg b/Script/Conf.cfg index 575e5f6ac4912072b12aa2ca8a8d8af8a711340b..67c4f350a734b8ca7c575c07863d358d5069d113 100755 --- a/Script/Conf.cfg +++ b/Script/Conf.cfg @@ -12,6 +12,9 @@ LogLevel: 'debug' # ERS severity level (DEBUG,INFO,WARNING,ERROR,CRITICAL) ERSLogLevel: 'debug' +# On / Off switch for ERS +ERS_enabled: True + # Email list which will receive error messages (list of strings) mailList: [] diff --git a/Script/Conf.py b/Script/Conf.py index 6a4e9b314cbd3181b5fca4c0074384c7779e4ac5..9234b0a57438a20b343605e87a02b49f1f282300 100755 --- a/Script/Conf.py +++ b/Script/Conf.py @@ -36,6 +36,9 @@ class Conf: # ERS severity level (DEBUG,INFO,WARNING,ERROR,CRITICAL) self.ERSLogLevel = cfg.ERSLogLevel + # On / Off switch for ERS + self.ERS_enabled = cfg.ERS_enabled + # Email list which will receive error messages (list of strings) self.mailList = cfg.mailList diff --git a/Script/CopyThread.py b/Script/CopyThread.py index c2a2d3d5091e625b907165c032c852863aad7125..42ca2752a60b98caac75056711dff00a3f806bd3 100755 --- a/Script/CopyThread.py +++ b/Script/CopyThread.py @@ -35,6 +35,7 @@ class CopyThread(threading.Thread): self.LogDir = self.conf.LogDir self.LogLevel = self.conf.LogLevel self.ERSLogLevel = self.conf.ERSLogLevel + self.ERS_enabled = self.conf.ERS_enabled self.exitFlag = False self.CopyList = [] @@ -50,13 +51,11 @@ class CopyThread(threading.Thread): self.logger = logging.getLogger('CopyThread') self.logger.addHandler(self.CopyLog) - ##### Setup ERS ##### - #only if there is a partition, try to add ers backend - import ers - from ispy import IPCPartition - if IPCPartition(conf.partition).isValid(): + ##### Add ERS handler ######### + if self.ERS_enabled: try: - #import ers + import ers + from ispy import IPCPartition #ers.addLoggingHandler('CopyThread') self.Copy_ERS_handler=ers.LoggingHandler() set_log_level(self.ERSLogLevel,self.Copy_ERS_handler) diff --git a/Script/DeleteThread.py b/Script/DeleteThread.py index c0abe9ab9849f1c7265aae6de53f1072966e571b..f85c2695d00bf3f5caeba108da24315868eef0e4 100755 --- a/Script/DeleteThread.py +++ b/Script/DeleteThread.py @@ -42,6 +42,7 @@ class DeleteThread(threading.Thread): self.LogDir = self.conf.LogDir self.LogLevel = self.conf.LogLevel self.ERSLogLevel = self.conf.ERSLogLevel + self.ERS_enabled = self.conf.ERS_enabled #### Import the function to resolve the merged file names ##### self.mergedChecker = None @@ -65,12 +66,11 @@ class DeleteThread(threading.Thread): self.logger = logging.getLogger('DeleteThread') self.logger.addHandler(self.DeleteLog) - #only if there is a partition, try to add ers backend - import ers - from ispy import IPCPartition - if IPCPartition(conf.partition).isValid(): + ##### Add ERS handler ######### + if self.ERS_enabled: try: - #import ers + import ers + from ispy import IPCPartition #ers.addLoggingHandler('DeleteThread') self.Del_ERS_handler=ers.LoggingHandler() set_log_level(self.ERSLogLevel,self.Del_ERS_handler) diff --git a/Script/ManagerThread.py b/Script/ManagerThread.py index 6a61c14374dce3f3bc8c09892feb582091f2cf57..04aa15b12986d6aec19156ad7a6bdfed52a31943 100755 --- a/Script/ManagerThread.py +++ b/Script/ManagerThread.py @@ -51,6 +51,7 @@ class ManagerThread(threading.Thread): self.LogDir = self.conf.LogDir self.LogLevel = self.conf.LogLevel self.ERSLogLevel = self.conf.ERSLogLevel + self.ERS_enabled = self.conf.ERS_enabled self.CopyFileList = [] self.ProblDict = {} @@ -68,12 +69,11 @@ class ManagerThread(threading.Thread): self.logger = logging.getLogger('ManagerThread') self.logger.addHandler(self.ManagerLog) - ##### Add ERS handler in case a partion is found ######### - import ers - from ispy import IPCPartition - if IPCPartition(conf.partition).isValid(): + ##### Add ERS handler ######### + if self.ERS_enabled: try: - #import ers + import ers + from ispy import IPCPartition #ers.addLoggingHandler('ManagerThread') self.manage_ERS_handler=ers.LoggingHandler() set_log_level(self.ERSLogLevel,self.manage_ERS_handler)