def __init__(self): """ 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 """ super(LoggingRoot, self).__init__() # this line removes some useless information from log records and improves # the performances logging._srcfile = None # pylint: disable=protected-access # initialize the root logger # actually a child of the root logger to avoid conflicts with other # libraries which used 'logging' self._logger = logging.getLogger('dirac') # prevent propagation to the root logger to avoid conflicts with external libraries # which want to use the root logger self._logger.propagate = False # here we redefine the custom name to the empty string to remove the "\" # in the display self._customName = "" # this level is not the Logging level, it is only used to send all log messages to the central logging system # to do such an operation, we need to let pass all log messages to the root logger, so all logger needs to be # at debug. Then, all the backends have a level associated to a Logging level, which can be changed with the # setLevel method of Logging, and these backends will choose to send the # log messages or not. self._logger.setLevel(LogLevels.DEBUG) # initialization of the UTC time # Actually, time.gmtime is equal to UTC time because it has its DST flag to 0 # which means there is no clock advance logging.Formatter.converter = time.gmtime # initialization of levels levels = LogLevels.getLevels() for level in levels: logging.addLevelName(levels[level], level) # initialization of the default backend self._setLevel(LogLevels.NOTICE) # use the StdoutBackend directly to avoid dependancy loop with ObjectLoader self._addBackend(StdoutBackend()) # configuration of the level and update of the format self.__configureLevel() self._generateBackendFormat()
def __init__(self): """ 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 """ super(LoggingRoot, self).__init__() # this line removes some useless information from log records and improves # the performances logging._srcfile = None # pylint: disable=protected-access # initialize the root logger # actually a child of the root logger to avoid conflicts with other # libraries which used 'logging' self._logger = logging.getLogger('dirac') # prevent propagation to the root logger to avoid conflicts with external libraries # which want to use the root logger self._logger.propagate = False # here we redefine the custom name to the empty string to remove the "\" # in the display self._customName = "" # this level is not the Logging level, it is only used to send all log messages to the central logging system # to do such an operation, we need to let pass all log messages to the root logger, so all logger needs to be # at debug. Then, all the backends have a level associated to a Logging level, which can be changed with the # setLevel method of Logging, and these backends will choose to send the # log messages or not. self._logger.setLevel(LogLevels.DEBUG) # initialization of the UTC time # Actually, time.gmtime is equal to UTC time because it has its DST flag to 0 # which means there is no clock advance logging.Formatter.converter = time.gmtime # initialization of levels levels = LogLevels.getLevels() for level in levels: logging.addLevelName(levels[level], level) # initialization of the default backend self._setLevel(LogLevels.NOTICE) # use the StdoutBackend directly to avoid dependancy loop with ObjectLoader self._addBackend(StdoutBackend()) # configuration of the level and update of the format self.__configureLevel() self._generateBackendFormat()
def __init__(self): """ 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 """ super(LoggingRoot, self).__init__() # this line removes some useless information from log records and improves the performances logging._srcfile = None # pylint: disable=protected-access # initialize the root logger, which turns out to be a child of root, and disable propagation # to avoid any conflicts with external libs that would use "logging" too self._logger = logging.getLogger("dirac") self._logger.propagate = False # here we redefine the custom name to the empty string to remove the "\" in the display self._customName = "" # initialization of levels levels = LogLevels.getLevels() for level in levels: logging.addLevelName(levels[level], level) # root Logger level is set to NOTICE by default self._logger.setLevel(LogLevels.NOTICE) # initialization of the UTC time # Actually, time.gmtime is equal to UTC time: it has its DST flag to 0 which means there is no clock advance logging.Formatter.converter = time.gmtime # initialization of the default backend # use the StdoutBackend directly to avoid dependancy loop with ObjectLoader self._addBackend(StdoutBackend) # configuration of the level and update the format self.__configureLevel()