Exemplo n.º 1
0
    def test_set_handlers_handler_level_config(self, tmpdir):
        config = get_config_content(__file__, 'my_test_logger')

        logger = LogmeLogger('handler_level_conf', config)

        handler = logger.handlers[0]

        assert handler.level == 20  # INFO
        assert handler.formatter._fmt == '{asctime}::{message}'
Exemplo n.º 2
0
    def test_reset_handler_rename(self):
        logger = LogmeLogger('rename_logger', self.config)

        assert logger.name == 'rename_logger'

        config = get_config_content(__file__, name='socket_config')
        logger.reset_config(config=config, name='logger_new_name')

        assert logger.name == 'logger_new_name'
def test_module_logger(caplog):
    my_logger = ModuleLogger(frame=1, name='test_module_logger')

    assert type(my_logger.logger) == LogmeLogger
    assert my_logger.name == 'test_module_logger'
    assert my_logger.master_formatter._fmt == '{asctime} - {name} - {levelname} - {module}::{funcName}::{message}'
    assert my_logger.config == get_config_content(__file__)

    my_logger.info('my test module logger content')
    assert caplog.record_tuples[0] == ('test_module_logger', 20,
                                       'my test module logger content')
def test_log_decorator_function(caplog, args, logger_name, config_name):
    global dummy_func

    dummy = LogDecorator(dummy_func, scope='function', **args)

    logger = dummy('blah')

    assert logger.name == logger_name
    assert logger.config == get_config_content(__file__, name=config_name)
    assert caplog.record_tuples[0] == (logger_name, 20,
                                       'my dummy function message.')
Exemplo n.º 5
0
def file_config_content(tmpdir):
    config = get_config_content(__file__, 'filehandler_conf')
    config['FileHandler']['filename'] = tmpdir.join(config['FileHandler']['filename'])

    yield config
Exemplo n.º 6
0
 def test_get_config_content_raise(self):
     with pytest.raises(InvalidConfig):
         get_config_content(__file__, 'blah')
Exemplo n.º 7
0
    def test_get_config_content(self, conf_name, expected_level):
        conf_content = get_config_content(__file__, conf_name)

        assert type(conf_content) == dict
        assert type(conf_content['FileHandler']) == dict
        assert conf_content['level'] == expected_level
Exemplo n.º 8
0
 def setup(cls):
     cls.config = get_config_content(__file__)
     cls.logger = LogmeLogger('test_logger', cls.config)