Logging

Logging

class DIRAC.FrameworkSystem.private.standardLogging.Logging.Logging(father=None, fatherName='', name='', customName='')

Bases: object

Logging is a wrapper of the logger object from the standard “logging” library which integrate some DIRAC concepts. It is the equivalent to the old gLogger object.

It is used like an interface to use the logger object of the “logging” library. Its purpose is to replace transparently the old gLogger object in the existing code in order to minimize the changes.

In this way, each Logging embed a logger of “logging”. It is possible to create sublogger, set and get the level of the embedded logger and create log messages with it.

Logging could delegate the initialization and the configuration to a factory of the root logger be it can not because it has to wrap the old gLogger.

Logging should not be instancied directly. It is LoggingRoot which is instancied and which instantiates Logging objects.

always(sMsg, sVarMsg='')

Always level

debug(sMsg, sVarMsg='')

Debug level

error(sMsg, sVarMsg='')

Error level

exception(sMsg='', sVarMsg='', lException=False, lExcInfo=False)

Exception level

fatal(sMsg, sVarMsg='')

Fatal level

flushAllMessages(exitCode=0)

flushAllMessages: Deleted method. Do not use it.

static getAllPossibleLevels()
Returns:a list of all levels available
getDisplayOptions()
Returns:the dictionary of the display options and their values. Must not be redefined
getLevel()
Returns:the name of the level
classmethod getName()
Returns:“system name/component name”
getSubLogger(subName, child=True)

Create a new Logging object, child of this Logging, if it does not exists.

Params subName:the name of the child Logging
getSubName()
Returns:the name of the logger
info(sMsg, sVarMsg='')

Info level

initialized()

initialized: Deleted method. Do not use it.

notice(sMsg, sVarMsg='')

Notice level

processMessage(messageObject)

processMessage: Deleted method. Do not use it.

registerBackend(desiredBackend, backendOptions=None)

Attach a backend to the Logging object. Convert backend name to backend class name to a Backend object and add it to the Logging object

Params desiredBackend:
 a name attaching to a backend type. list of the possible values: [‘stdout’, ‘stderr’, ‘file’, ‘server’]
Params backendOptions:
 dictionary of different backend options. example: FileName=’/tmp/log.txt’
registerBackends(desiredBackends, backendOptions=None)

Attach a list of backends to the Logging object. Convert backend name to backend class name to a Backend object and add it to the Logging object

Params desiredBackends:
 a list of different names attaching to differents backends. list of the possible values: [‘stdout’, ‘stderr’, ‘file’, ‘server’]
Params backendOptions:
 dictionary of different backend options. example: FileName=’/tmp/log.txt’
setLevel(levelName)

Check if the level name exists and get the integer value before setting it.

Params levelName:
 string representing the level to give to the logger
Returns:boolean representing if the setting is done or not
showHeaders(yesno=True)

Depending on the value, display or not the prefix of the message.

Params yesno:boolean determining the behaviour of the display
showStack()

Display a debug message without any content.

Returns:boolean, True if the message is sent, else False
showThreadIDs(yesno=True)

Depending on the value, display or not the thread ID.

Params yesno:boolean determining the behaviour of the display
shown(levelName)

Determine if messages with a certain level will be displayed or not.

Params levelName:
 string representing the level to analyse
Returns:boolean which give the answer
verbose(sMsg, sVarMsg='')

Verbose level

warn(sMsg, sVarMsg='')

Warn