hw_drivers/exception_logger.py

24 lines
476 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
import sys
class ExceptionLogger:
"""
Redirect Exceptions to the logger to keep track of them in the log file.
"""
def __init__(self):
self.logger = logging.getLogger()
def write(self, message):
if message != '\n':
self.logger.error(message)
def flush(self):
pass
sys.stderr = ExceptionLogger()