[FIX] hw_drivers: Redirect exceptions to log file
Exceptions were logged to stderr so we couldn't see them when Odoo was running as a service on the IoT Box. We now redirect stderr to the logger to see track errors in the log file too. closes odoo/odoo#41028 Taskid: 2146835 X-original-commit: 54a1919cbc37f5832ce110605c29b222c7a5bfe9 Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ from re import sub, finditer
|
||||
import urllib3
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
from importlib import util
|
||||
import v4l2
|
||||
from fcntl import ioctl
|
||||
@@ -97,6 +98,27 @@ class StatusController(http.Controller):
|
||||
with open(image, 'rb') as f:
|
||||
return f.read()
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Log Exceptions
|
||||
#----------------------------------------------------------
|
||||
|
||||
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.err(message)
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
|
||||
sys.stderr = ExceptionLogger()
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Drivers
|
||||
#----------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user