StdoutBackend

StdoutBackend wrapper

class DIRAC.Resources.LogBackends.StdoutBackend.StdoutBackend

Bases: DIRAC.Resources.LogBackends.AbstractBackend.AbstractBackend

StdoutBackend is used to create an abstraction of the handler and the formatter concepts from logging. Here, we gather a StreamHandler object and a BaseFormatter.

  • StreamHandler is from the standard logging library: it is used to write log messages in a desired stream so it needs a name: here it is stdout.
  • ColorBaseFormatter is a custom Formatter object, created for DIRAC in order to get the appropriate display with color. You can find it in FrameworkSystem/private/standardLogging/Formatter
__init__()

Initialization of the backend. _handler and _formatter can be custom objects. If it is the case, you can find them in FrameworkSystem/private/standardLogging/Formatter or Handler.

Params _handler:
 handler object from ‘logging’. Ex: StreamHandler(), FileHandler()…
Params _formatter:
 the name of a formatter object from logging. Ex: BaseFormatter
static createFormat(options)

Create a format from the options given in parameters.

Params options:dictionary of options of the Logging which wants a new format
Params level:integer representing the level of the Logging object which wants a new format
Returns:tuple containing two strings: a format and a date format
createHandler(parameters=None)

Each backend can initialize its attributes and create its handler with them.

Params parameters:
 dictionary of parameters. ex: {‘FileName’: file.log}
getHandler()
Returns:the handler
setFormat(fmt, datefmt, options)

Each backend give a format to their formatters and attach them to their handlers.

Params fmt:string representing the log format
Params datefmt:string representing the date format
Params component:
 string represented as “system/component”
Params options:dictionary of logging options. ex: {‘Color’: True}
setLevel(level)

Configure the level of the handler associated to the backend.

Params level:integer representing a level