Backend wrapper

class DIRAC.Resources.LogBackends.AbstractBackend.AbstractBackend(handler, formatter)

Bases: object

AbstractBackend is used to create an abstraction of handler and formatter concepts from ‘logging’. It corresponds to the backend concept of the old gLogger. It is useful for different reasons:

  • to gather handler and formatter, in DIRAC, each handler must be bind with a specific formatter so it is more simple and more clear to create an object for this job.
  • each backend can get its options and format them to give them to the handler, in DIRAC, it is possible to add backend options in the cfgfile. For example, for a file, you can give the filename that you want to write log inside. The backend allows to each handler to get its own options as parameters. Again, it is more clear and more simple to have a specific object for this job.

In this way, we have an object composed by one handler and one formatter name. The purpose of the object is to get cfg options to give them to the handler, and to set the format of the handler when the display must be changed.

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

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

Params parameters:
 dictionary of parameters. ex: {‘FileName’: file.log}
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}

Configure the level of the handler associated to the backend.

Params level:integer representing a level