I've got this code:
def __init__(self, log_level: str = None):
self.log_level = log_level if log_level and log_level.lower() in ['debug', 'warning', 'info',
'error'] else 'error'
self.logger = logging.getLogger(__name__)
self.logger.setLevel(getattr(logging, self.log_level.upper()))
And i want to create simple logger without configurations. This code is not working without this line:
logging.basicConfig()
Why? I can't really understand. So if you try something like this:
self.logger = logging.getLogger(__name__)
self.logger.setLevel(logging.DEBUG)
self.logger.debug('test')
it would not print anything. But this will:
logging.basicConfig()
self.logger = logging.getLogger(__name__)
self.logger.setLevel(logging.DEBUG)
self.logger.debug('test')
or this:
self.logger = logging.getLogger(__name__)
self.logger.setLevel(logging.DEBUG)
logging.debug("don't care")
self.logger.debug('test')