Coverage for ion/util/ionlog : 58.06%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#!/usr/bin/env python
@file ion/util/ionlog.py @author Michael Meisinger @brief Abstracts from any form of logging in ION """
""" Factory for producing logger objects with additional handlers. A global instance of this factory is declared in this module, and is used by the getLogger global used all over ioncore-python. """ """ Initializer. """
""" Creates an instance of a logger. Adds any registered handlers with this factory.
Note: as this method is called typically on module load, if you haven't registered a handler at this time, that instance of a logger will not have that handler. """ logger.addHandler(handler)
""" Adds a handler to be added to the logger requested with get_logger. The handler must be derived from logging.Handler. """ self._handlers.append(handler)
""" Removes a handler. """ self._handlers.remove(handler)
# declare global instance
""" This function is used to assign every module in the code base a separate logger instance. Currently it just delegates to Python logging. """
""" Adds extra parameters to the Python logging loggers, for process identification. """
from random import choice if name == "procid": result = "p1" elif name == "procname": result = "n1" else: result = self.__dict__.get(name, "?") return result
""" To allow iteration over keys, which will be merged into the LogRecord dict before formatting and output. """ keys = ["procid", "procname"] keys.extend(self.__dict__.keys()) return keys.__iter__() |