def __init__(self, level=None): if level is None: self.logger = mrglog.get_logger('A class logger', module=True) else: self.logger = mrglog.get_logger('A class logger', module=True, verbose_lvl=level)
def test_error_message(capfd): msg_text = 'some content' # create logger module, we can't move this into fixture because # of capfd module logger = mrglog.get_logger('test_error_message') # log single message logger.error(msg_text) # get snapshot of the stdout and stderr out, err = capfd.readouterr() # check expected format: "[12:59:09,804] [ ERROR ] main_test:: msg_text" assert msg_text in out assert "ERROR" in out
def get_logger(*args, **kwargs): if 'verbose_lvl' not in kwargs: kwargs['verbose_lvl'] = 0 if 'output' not in kwargs: kwargs['output'] = ['std', 'txt'] logger = mrglog.get_logger(*args, **kwargs) for handler in logger.handlers: # logging.FileHandler is probably inherited from logging.StreamHandler # hence isinstance is not working properly # if isinstance(handler, logging.StreamHandler): if 'logging.StreamHandler' in str(handler): handler.addFilter(No_log_filter()) return logger
def get_logger(*args, **kwargs): if 'verbose_lvl' not in kwargs: kwargs['verbose_lvl'] = 0 return mrglog.get_logger(*args, **kwargs)