Skip to content

Commit

Permalink
adapt log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangWaltenberger committed Apr 11, 2024
1 parent 0396094 commit 0c845ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions smodels/base/smodelsLogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion unittests/runCompleteTestSuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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? """
Expand Down
4 changes: 2 additions & 2 deletions unittests/testCombined.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions unittests/unitTestHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c845ad

Please sign in to comment.