From 0c845adaa77a53e69d3ca52ba43384532f5eae00 Mon Sep 17 00:00:00 2001 From: Wolfgang Waltenberger Date: Thu, 11 Apr 2024 15:43:05 +0200 Subject: [PATCH] adapt log levels --- smodels/base/smodelsLogging.py | 9 +++++---- unittests/runCompleteTestSuite.py | 2 +- unittests/testCombined.py | 4 ++-- unittests/unitTestHelpers.py | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/smodels/base/smodelsLogging.py b/smodels/base/smodelsLogging.py index bf74f3476c..f3562fa78f 100755 --- a/smodels/base/smodelsLogging.py +++ b/smodels/base/smodelsLogging.py @@ -122,7 +122,7 @@ def getLogger (): logger = getLogger() def getLogLevel( asString=False ): - """ obtain the current log level. + """ obtain the current log level. :params asString: return string, not number. """ # return logger.level @@ -131,7 +131,7 @@ def getLogLevel( asString=False ): return ret lvlNames= { logging.DEBUG: "debug", logging.INFO: "info", logging.WARNING: "warning", logging.ERROR: "error", - logging.CRITICAL: "critical", logging.FATAL: "FATAL" } + logging.CRITICAL: "critical", logging.FATAL: "fatal" } lvl = list ( lvlNames.keys() ) lvl.sort( reverse = True) for l in lvl: @@ -151,8 +151,9 @@ def setLogLevel ( level ): return level = level.lower() levels = { "debug": logging.DEBUG, "info": logging.INFO, - "warn": logging.WARNING, - "warning": logging.WARNING, "error": logging.ERROR } + "warn": logging.WARNING, "warning": logging.WARNING, + "error": logging.ERROR, "critical": logging.CRITICAL, + "fatal": logging.FATAL } if not level in levels: logger.error ( "Unknown log level ``%s'' supplied!" % level ) return diff --git a/unittests/runCompleteTestSuite.py b/unittests/runCompleteTestSuite.py index 3c1eb18ff5..a2c0a49432 100755 --- a/unittests/runCompleteTestSuite.py +++ b/unittests/runCompleteTestSuite.py @@ -25,7 +25,7 @@ print ( "Error: python v",sys.version,"needs unittest2. Please install." ) sys.exit() from smodels.base.smodelsLogging import setLogLevel -setLogLevel ( "error" ) +setLogLevel ( "fatal" ) def isInReducedSet ( t ): """ is t in the reduced set of unit tests? """ diff --git a/unittests/testCombined.py b/unittests/testCombined.py index c2bd2050e2..6b80fdbccd 100755 --- a/unittests/testCombined.py +++ b/unittests/testCombined.py @@ -14,13 +14,13 @@ sys.path.insert(0, "../") import unittest from unitTestHelpers import equalObjs, runMain, importModule -from smodels.base.smodelsLogging import logger, setLogLevel -setLogLevel('debug') class CombinedTest(unittest.TestCase): def testCombinedResult(self): filename = "./testFiles/slha/gluino_squarks.slha" + from smodels.base.smodelsLogging import logger, setLogLevel + setLogLevel ( "fatal" ) outputfile = runMain(filename, inifile="testParameters_agg.ini", suppressStdout=True) smodelsOutput = importModule(outputfile) from gluino_squarks_default_agg import smodelsOutputDefault diff --git a/unittests/unitTestHelpers.py b/unittests/unitTestHelpers.py index 50a5606a1e..05940aca24 100644 --- a/unittests/unitTestHelpers.py +++ b/unittests/unitTestHelpers.py @@ -124,7 +124,7 @@ def equalObjs(obj1, obj2, allowedRelDiff, ignore=[], where=None, fname=None, # For numbers with units, do not check for absolute difference ret = (rel_diff.asNumber() < allowedRelDiff) if not ret: - logger.error("values %s and %s differ by %s" % (obj1, obj2, rel_diff)) + logger.error( f"values {obj1} and {obj2} differ by {rel_diff}" ) return ret elif isinstance(obj1, float): if obj1 == obj2: @@ -221,7 +221,7 @@ def runMain(filename, timeout=0, suppressStdout=True, development=False, # level = 'debug' level = 'info' if suppressStdout: - level = 'error' + level = 'fatal' to = os.devnull database = None from smodels.base import runtime @@ -321,7 +321,7 @@ def getEdges(sms): ''' Convenience function to convert the edges to strings. ''' - edges = sorted([(str(mom),str(daughter)) + edges = sorted([(str(mom),str(daughter)) for mom,daughter in sms.edges]) return edges