6 """Athena Python-side logging."""
8 from AthenaCommon
import Constants
13 __author__ =
'Wim Lavrijsen (WLavrijsen@lbl.gov)'
15 __all__ = [
'log',
'logging',
'AthError' ]
24 logging.VERBOSE = logging.DEBUG - 1
25 logging.ALL = logging.DEBUG - 2
26 logging.addLevelName( logging.VERBOSE,
'VERBOSE' )
27 logging.addLevelName( logging.ALL,
'ALL' )
32 __levelmap = { Constants.ALL : logging.ALL,
33 Constants.VERBOSE : logging.VERBOSE,
34 Constants.DEBUG : logging.DEBUG,
35 Constants.INFO : logging.INFO,
36 Constants.WARNING : logging.WARNING,
37 Constants.ERROR : logging.ERROR,
38 Constants.FATAL : logging.FATAL }
46 super( AthenaLogger, self ).
setLevel( level )
49 for h
in log.handlers :
51 fmt = h.formatter.format
53 datefmt = h.formatter.datefmt
55 h.setFormatter( logging.Formatter( fmt = fmt, datefmt = datefmt ) )
71 def all( self, msg, *args, **kwargs):
72 if self.manager.disable >= logging.ALL:
74 if logging.ALL >= self.getEffectiveLevel():
75 self._log( logging.ALL, msg, args, **kwargs )
78 if self.manager.disable >= logging.VERBOSE:
80 if logging.VERBOSE >= self.getEffectiveLevel():
81 self._log( logging.VERBOSE, msg, args, **kwargs )
86 logging.setLoggerClass( AthenaLogger )
88 logging.Logger.root = logging.root
89 logging.Logger.manager = logging.Manager( logging.Logger.root )
93 log = logging.getLogger()
97 hdlr = logging.StreamHandler( sys.stdout )
98 frmt = logging.Formatter(
"Py:%(name)-14s%(levelname)8s %(message)s" )
99 hdlr.setFormatter( frmt )
100 for h
in log.handlers:
101 if h.formatter._fmt == logging.BASIC_FORMAT:
102 log.removeHandler( h )
104 log.addHandler( hdlr )
109 raise RuntimeError( descr )