def getLogger(name=None, fmt='%(message)s'): log = realGetLogger(name) handler = ColourStreamHandler() handler.setLevel(DEBUG) handler.setFormatter(Formatter(fmt)) log.addHandler(handler) log.setLevel(DEBUG) log.propagate = 0 # Don't bubble up to the root logger return log
def getLogger(name=None, fmt='%(message)s'): """ Get and initialize a colourised logging instance if the system supports it as defined by the log.has_colour :param name: Name of the logger :type name: str :param fmt: Message format to use :type fmt: str :return: Logger instance :rtype: Logger """ log = realGetLogger(name) handler = ColourStreamHandler() handler.setLevel(DEBUG) handler.setFormatter(Formatter(fmt)) log.addHandler(handler) log.setLevel(DEBUG) log.propagate = 0 return log
def getLogger(name=None, fmt='%(message)s', lvl="DEBUG"): """ Get and initialize a colourised logging instance if the system supports it as defined by the log.has_colour :param name: Name of the logger :type name: str :param fmt: Message format to use :type fmt: str :return: Logger instance :rtype: Logger """ log = realGetLogger(name) # Only enable colour if support was loaded properly handler = ColourStreamHandler() handler.setLevel(DEBUG) handler.setFormatter(Formatter(fmt)) log.addHandler(handler) log.setLevel(lvl) log.propagate = 0 # Don't bubble up to the root logger return log
def getLogger(name=None, fmt='[%(processName)s/%(filename)s:%(lineno)s/%(levelname)s] %(relativeCreated)d: %(message)s'): """ Get and initialize a colourised logging instance if the system supports it as defined by the log.has_colour :param name: Name of the logger :type name: str :param fmt: Message format to use :type fmt: str :return: Logger instance :rtype: Logger """ log = realGetLogger(name) if not len(log.handlers): # Only enable colour if support was loaded properly handler = ColourStreamHandler() if has_colour else StreamHandler() handler.setLevel(DEBUG) handler.setFormatter(Formatter(fmt)) log.addHandler(handler) log.setLevel(DEBUG) log.propagate = False return log
def getLogger(name=None, fmt='[%(processName)s/%(threadName)s/%(levelname)s] %(relativeCreated)d: %(message)s'): """ Get and initialize a colourised logging instance if the system supports it as defined by the log.has_colour :param name: Name of the logger :type name: str :param fmt: Message format to use :type fmt: str :return: Logger instance :rtype: Logger """ log = realGetLogger(name) if not len(log.handlers): # Only enable colour if support was loaded properly handler = ColourStreamHandler() if has_colour else StreamHandler() handler.setLevel(DEBUG) handler.setFormatter(Formatter(fmt)) log.addHandler(handler) log.setLevel(DEBUG) log.propagate = False return log
def getLogger(name=None, fmt='%(message)s'): """ Get and initialize a colourised logging instance if the system supports it as defined by the log.has_colour :param name: Name of the logger :type name: str :param fmt: Message format to use :type fmt: str :return: Logger instance :rtype: Logger """ global loggers, log_level try: return loggers[name] except KeyError: logger = realGetLogger(name) logger.setLevel(log_level) # Only enable colour if support was loaded properly handler = ColourStreamHandler() if has_colour else StreamHandler() handler.setFormatter(Formatter(fmt)) logger.addHandler(handler) loggers[name] = logger return logger