From 63f57b6a77dbb23d0ca6d1926c033438b6c895e4 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 30 Aug 2021 14:43:44 +0200 Subject: [PATCH] events: improve logging for task exceptions Signed-off-by: Jens Langhammer --- authentik/events/monitored_tasks.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/authentik/events/monitored_tasks.py b/authentik/events/monitored_tasks.py index b7575d8dd..e672678ce 100644 --- a/authentik/events/monitored_tasks.py +++ b/authentik/events/monitored_tasks.py @@ -11,6 +11,7 @@ from django.core.cache import cache from prometheus_client import Gauge from authentik.events.models import Event, EventAction +from authentik.lib.utils.errors import exception_to_string GAUGE_TASKS = Gauge( "authentik_system_tasks", @@ -174,9 +175,7 @@ class MonitoredTask(Task): ).save(self.result_timeout_hours) Event.new( EventAction.SYSTEM_TASK_EXCEPTION, - message=( - f"Task {self.__name__} encountered an error: " "\n".join(self._result.messages) - ), + message=(f"Task {self.__name__} encountered an error: {exception_to_string(exc)}"), ).save() return super().on_failure(exc, task_id, args, kwargs, einfo=einfo)