LoggingRoot

Logging Root

class DIRAC.FrameworkSystem.private.standardLogging.LoggingRoot.LoggingRoot(*args, **kwargs)

Bases: Logging

LoggingRoot is a particular Logging object: the first parent of the chain.

  • It is the one that initializes the root logger of the standard logging library and it configures it

  • As it defines the default behaviour of the Logging objects, it needs a specific class

  • It is unique, there is one and only one parent at the top of the chain: this justifies the usage of a Singleton

class LocalSubLogger(logger: Logging, extra: dict)

Bases: object

This is inspired from the standard LoggingAdapter. The idea is to provide an interface which looks like a Logger, but does not implement all the features. You can basically just create it, and log messages. You cannot create subLogger from it

This is to be used for very short lived sub logger. It allows to give context information (like a jobID) without creating a new logging object, which ends up eating all the memory (see https://github.com/DIRACGrid/DIRAC/issues/5280)

__init__(logger: Logging, extra: dict)
Parameters:
  • loggerLogging object on which to be based

  • extra – dictionary of extra information to be passed

always(sMsg: str, sVarMsg: str = '') bool

Always level

debug(sMsg: str, sVarMsg: str = '') bool

Debug level

error(sMsg: str, sVarMsg: str = '') bool

Error level

exception(sMsg: str = '', sVarMsg: str = '', lException: bool = False, lExcInfo: bool = False) bool

Exception level

fatal(sMsg: str, sVarMsg: str = '') bool

Fatal level

info(sMsg: str, sVarMsg: str = '') bool

Info level

notice(sMsg: str, sVarMsg: str = '') bool

Notice level

verbose(sMsg: str, sVarMsg: str = '') bool

Verbose level

warn(sMsg: str, sVarMsg: str = '') bool

Warn

__init__()

Initialization of the LoggingRoot object. LoggingRoot :

  • initialize the UTC time

  • set the correct level defines by the user, or the default

  • add the custom level to logging: verbose, notice, always

  • register a default backend (stdout): all messages will be displayed here

  • update the format according to the command line argument

always(sMsg: str, sVarMsg: str = '') bool

Always level

debug(sMsg: str, sVarMsg: str = '') bool

Debug level

disableLogsFromExternalLibs()

Disable the display of the logs coming from external libraries

Warning

This method should only be used for debugging purposes.

enableLogsFromExternalLibs()

Enable the display of the logs coming from external libraries

Warning

This method should only be used for debugging purposes.

error(sMsg: str, sVarMsg: str = '') bool

Error level

exception(sMsg: str = '', sVarMsg: str = '', lException: bool = False, lExcInfo: bool = False) bool

Exception level

fatal(sMsg: str, sVarMsg: str = '') bool

Fatal level

static getAllPossibleLevels() list[str]
Returns:

a list of all levels available

getDisplayOptions() dict[str, bool]
Returns:

the dictionary of the display options and their values. Must not be redefined

getLevel() str
Returns:

the name of the level

getLocalSubLogger(subName: str) LocalSubLogger

Create a subLogger which is meant to have very short lifetime, (e.g. when you want to add the jobID in the name)

Warning

This is a light version of a logger, read the documentation of LocalSubLogger carefully

Parameters:

subName (str) – name of the child Logging

classmethod getName() str
Returns:

“system name/component name”

getSubLogger(subName: str) Logging

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

Warning

For very short lived sub logger, consider getLocalSubLogger() instead

Parameters:

subName (str) – name of the child Logging

getSubName() str
Returns:

the name of the logger

info(sMsg: str, sVarMsg: str = '') bool

Info level

initialize(systemName: str, cfgPath: str, forceInit: bool = False)

Configure the root Logging. It can be possible to:

  • attach some backends to it: LogBackends = stdout,stderr,file,server

  • attach backend options: BackendOptions { FileName = /tmp/file.log }

  • attach filters to it and to some backends: see LogFilters

  • add colors: LogColor = True

  • precise a level: LogLevel = DEBUG

Parameters:
  • systemName (str) – <system name>/<component name>

  • cfgPath (str) – configuration path

  • forceInit (bool) – Force the initialization even if it had already happened. This should not be used !! The only case is LocalConfiguration.enableCS In order to take into account extensions’ backends

instance = <DIRAC.FrameworkSystem.private.standardLogging.LoggingRoot.LoggingRoot object>
notice(sMsg: str, sVarMsg: str = '') bool

Notice level

registerBackend(desiredBackend: str, backendOptions: dict | None = None, backendFilters: dict | None = None) bool

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

Parameters:
  • desiredBackend – a name attaching to a backend type. List of possible values: [‘stdout’, ‘stderr’, ‘file’]

  • backendOptions – dictionary of different backend options. Example: FileName=’/tmp/log.txt’

  • backendFilters – dictionary of different backend filters. Example: {‘ModuleFilter’: {‘dirac’: ‘ERROR’}}

Returns:

Success or failure of registration

Return type:

bool

setLevel(levelName: str) bool

Check if the level name exists and set it.

Parameters:

levelName – string representing the level to give to the logger

Returns:

boolean representing if the setting is done or not

showContexts(yesno: bool = True)

Depending on the value, display or not the context of the message. Make sure to enable the headers: showHeaders(True) before

Parameters:

yesno (bool) – determine the log record format

showHeaders(yesno: bool = True)

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

Parameters:

yesno (bool) – determine the log record format

showStack() bool

Display a debug message without any content.

Returns:

boolean, True if the message is sent, else False

showThreadIDs(yesno: bool = True)

Depending on the value, display or not the thread ID. Make sure to enable the headers: showHeaders(True) before

Parameters:

yesno (bool) – determe the log record format

showTimeStamps(yesno: bool = True)

Depending on the value, display or not the timestamp of the message. Make sure to enable the headers: showHeaders(True) before

Parameters:

yesno (bool) – determine the log record format

shown(levelName: str) bool

Determine whether messages with a certain level will be displayed.

Parameters:

levelName – string representing the level to analyse

Returns:

boolean which give the answer

verbose(sMsg: str, sVarMsg: str = '') bool

Verbose level

warn(sMsg: str, sVarMsg: str = '') bool

Warn