exception_logger.py 476 B

123456789101112131415161718192021222324
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. import logging
  4. import sys
  5. class ExceptionLogger:
  6. """
  7. Redirect Exceptions to the logger to keep track of them in the log file.
  8. """
  9. def __init__(self):
  10. self.logger = logging.getLogger()
  11. def write(self, message):
  12. if message != '\n':
  13. self.logger.error(message)
  14. def flush(self):
  15. pass
  16. sys.stderr = ExceptionLogger()