verbosity.py 586 B

123456789101112131415161718192021222324
  1. import logging
  2. import borgmatic.logger
  3. VERBOSITY_DISABLED = -2
  4. VERBOSITY_ERROR = -1
  5. VERBOSITY_ANSWER = 0
  6. VERBOSITY_SOME = 1
  7. VERBOSITY_LOTS = 2
  8. def verbosity_to_log_level(verbosity):
  9. '''
  10. Given a borgmatic verbosity value, return the corresponding Python log level.
  11. '''
  12. borgmatic.logger.add_custom_log_levels()
  13. return {
  14. VERBOSITY_DISABLED: logging.DISABLED,
  15. VERBOSITY_ERROR: logging.ERROR,
  16. VERBOSITY_ANSWER: logging.ANSWER,
  17. VERBOSITY_SOME: logging.INFO,
  18. VERBOSITY_LOTS: logging.DEBUG,
  19. }.get(verbosity, logging.WARNING)