Use a named logger

This commit is contained in:
Valentin Niess
2023-11-10 10:18:12 +01:00
parent e596fec38b
commit e249fdebdb
4 changed files with 29 additions and 24 deletions

View File

@@ -7,17 +7,25 @@ __all__ = ['debug', 'log']
# Configure the logger
logging.basicConfig(
format='[%(asctime)s] %(message)s',
level=logging.INFO
level=logging.ERROR
)
logging.getLogger('python-appimage').setLevel(logging.INFO)
def log(task, fmt, *args):
'''Log a standard message
'''
logging.info('%-8s ' + fmt, task, *args)
logging.getLogger('python-appimage').info('%-8s ' + fmt, task, *args)
def debug(task, fmt, *args):
'''Report some debug information
'''
logging.debug('%-8s ' + fmt, task, *args)
logging.getLogger('python-appimage').debug('%-8s ' + fmt, task, *args)
def set_level(level):
'''Set the threshold for logs
'''
level = getattr(logging, level)
logging.getLogger('python-appimage').setLevel(level)