diff --git a/src/backend/InvenTree/InvenTree/exceptions.py b/src/backend/InvenTree/InvenTree/exceptions.py index 61bde3b275..597f1f5063 100644 --- a/src/backend/InvenTree/InvenTree/exceptions.py +++ b/src/backend/InvenTree/InvenTree/exceptions.py @@ -25,6 +25,7 @@ def log_error( error_data: Optional[str] = None, scope: Optional[str] = None, plugin: Optional[str] = None, + user_id: Optional[int] = None, ): """Log an error to the database. @@ -37,6 +38,7 @@ def log_error( error_data: The error data (optional, overrides 'data') scope: The scope of the error (optional) plugin: The plugin name associated with this error (optional) + user_id: The user ID associated with this error (optional) """ import InvenTree.ready @@ -71,6 +73,9 @@ def log_error( except AttributeError: data = 'No traceback information available' + if user_id: + data = f'User ID: {user_id}\n{data}' + # Log error to stderr logger.error(info)