def basic_config(level: int = logging.INFO, log_format: Union[str, LogFormat] = LogFormat.color, buffered: bool = True, buffer_size: int = 1024, flush_interval: float = 0.2, loop=None, **kwargs): if isinstance(level, str): level = getattr(logging, level.upper()) logging.basicConfig() logger = logging.getLogger() logger.handlers.clear() if isinstance(log_format, str): log_format = LogFormat[log_format] handler = create_logging_handler(log_format, **kwargs) if buffered: handler = wrap_logging_handler( handler, buffer_size=buffer_size, flush_interval=flush_interval, loop=loop, ) logging.basicConfig(level=level, handlers=[handler])
def test_invalid_handler(): with pytest.raises(NotImplementedError): create_logging_handler('example.com')