log.py 667 B

12345678910111213141516171819202122232425262728293031
  1. import logging
  2. __all__ = ['debug', 'log']
  3. # Configure the logger
  4. logging.basicConfig(
  5. format='[%(asctime)s] %(message)s',
  6. level=logging.ERROR
  7. )
  8. logging.getLogger('python-appimage').setLevel(logging.INFO)
  9. def log(task, fmt, *args):
  10. '''Log a standard message
  11. '''
  12. logging.getLogger('python-appimage').info('%-8s ' + fmt, task, *args)
  13. def debug(task, fmt, *args):
  14. '''Report some debug information
  15. '''
  16. logging.getLogger('python-appimage').debug('%-8s ' + fmt, task, *args)
  17. def set_level(level):
  18. '''Set the threshold for logs
  19. '''
  20. level = getattr(logging, level)
  21. logging.getLogger('python-appimage').setLevel(level)