mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Inject log_ref into all is_unit_operation failures
This commit is contained in:
parent
01ccab5252
commit
37f0c30ddc
2 changed files with 10 additions and 3 deletions
|
@ -1124,8 +1124,7 @@ def app_install(
|
||||||
|
|
||||||
raise YunohostError(
|
raise YunohostError(
|
||||||
failure_message_with_debug_instructions,
|
failure_message_with_debug_instructions,
|
||||||
raw_msg=True,
|
raw_msg=True
|
||||||
log_ref=operation_logger.name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Clean hooks and add new ones
|
# Clean hooks and add new ones
|
||||||
|
|
|
@ -35,7 +35,7 @@ from logging import FileHandler, getLogger, Formatter
|
||||||
|
|
||||||
from moulinette import m18n, msettings
|
from moulinette import m18n, msettings
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
from yunohost.utils.error import YunohostError
|
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||||
from yunohost.utils.packages import get_ynh_package_version
|
from yunohost.utils.packages import get_ynh_package_version
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
from moulinette.utils.filesystem import read_file, read_yaml
|
from moulinette.utils.filesystem import read_file, read_yaml
|
||||||
|
@ -635,6 +635,14 @@ class OperationLogger(object):
|
||||||
return
|
return
|
||||||
if error is not None and not isinstance(error, str):
|
if error is not None and not isinstance(error, str):
|
||||||
error = str(error)
|
error = str(error)
|
||||||
|
|
||||||
|
# When the error happen's in the is_unit_operation try/except,
|
||||||
|
# we want to inject the log ref in the exception, such that it may be
|
||||||
|
# transmitted to the webadmin which can then redirect to the appropriate
|
||||||
|
# log page
|
||||||
|
if isinstance(error, Exception) and not isinstance(error, YunohostValidationError):
|
||||||
|
error.log_ref = operation_logger.name
|
||||||
|
|
||||||
self.ended_at = datetime.utcnow()
|
self.ended_at = datetime.utcnow()
|
||||||
self._error = error
|
self._error = error
|
||||||
self._success = error is None
|
self._success = error is None
|
||||||
|
|
Loading…
Add table
Reference in a new issue