oca-ocb-core/odoo-bringout-oca-ocb-iot_drivers/iot_drivers/exception_logger.py
Ernad Husremovic aee3ee8bf7 add missing payment providers and iot modules for 19.0
Add 19 payment provider modules needed by the sale module:
payment_adyen, payment_aps, payment_asiapay, payment_authorize,
payment_buckaroo, payment_demo, payment_dpo, payment_flutterwave,
payment_iyzico, payment_mercado_pago, payment_mollie, payment_nuvei,
payment_paymob, payment_paypal, payment_razorpay, payment_redsys,
payment_stripe, payment_worldline, payment_xendit

Add 3 IoT modules needed for point_of_sale:
iot_base, iot_box_image, iot_drivers

Note: Stripe test API keys replaced with placeholders.

🤖 assisted by claude
2026-03-09 15:45:22 +01:00

38 lines
840 B
Python

from io import StringIO
import logging
import sys
from odoo.addons.iot_drivers.tools.system import IS_TEST
_logger = logging.getLogger(__name__)
class ExceptionLogger:
"""
Redirect any unhandled python exception to the logger to keep track of them in the log file.
"""
def __init__(self):
self._buffer = StringIO()
def write(self, message):
self._buffer.write(message)
if message.endswith('\n'):
self._flush_buffer()
def _flush_buffer(self):
self._buffer.seek(0)
_logger.error(self._buffer.getvalue().rstrip('\n'))
self._buffer = StringIO() # Reset the buffer
def flush(self):
if self._buffer.tell() > 0:
self._flush_buffer()
def close(self):
self.flush()
if not IS_TEST:
sys.stderr = ExceptionLogger()