From 38ae233a745b091cf787fca1d6b0339555991602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kita?= Date: Mon, 10 Jun 2024 14:23:31 +0200 Subject: [PATCH] Use Logger.error to print original error while handling action returned by callback. Improve formatting. --- lib/membrane/core/callback_handler.ex | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/membrane/core/callback_handler.ex b/lib/membrane/core/callback_handler.ex index 186e50e04..4f1bafd25 100644 --- a/lib/membrane/core/callback_handler.ex +++ b/lib/membrane/core/callback_handler.ex @@ -185,7 +185,7 @@ defmodule Membrane.Core.CallbackHandler do Error handling actions returned by callback #{inspect(state.module)}.#{callback} """) - log_debug_orginal_error(actions, e, __STACKTRACE__) + log_error_orginal_error(actions, e, __STACKTRACE__) reraise e, __STACKTRACE__ end @@ -197,10 +197,11 @@ defmodule Membrane.Core.CallbackHandler do rescue e -> Membrane.Logger.error(""" - Error handling action #{inspect(action)} returned by callback #{inspect(state.module)}.#{callback} + Error handling action returned by callback #{inspect(state.module)}.#{callback}. + Action: #{inspect(action, pretty: true)} """) - log_debug_orginal_error(action, e, __STACKTRACE__) + log_error_orginal_error(action, e, __STACKTRACE__) reraise e, __STACKTRACE__ end @@ -212,15 +213,12 @@ defmodule Membrane.Core.CallbackHandler do # We log it, because sometimes, for some reason, crashing process doesn't cause # printing error logs on stderr, so this debug log allows us to get some info # about what happened in case of process crash - defp log_debug_orginal_error(action_or_actions, error, stacktrace) do + defp log_error_orginal_error(action_or_actions, error, stacktrace) do action_or_actions = if(is_list(action_or_actions), do: "actions ", else: "action ") <> inspect(action_or_actions, limit: :infinity) - Membrane.Logger.debug(""" - Error while handling #{action_or_actions} - - Orginal error: + Membrane.Logger.error(""" #{inspect(error, pretty: true, limit: :infinity)} #{Exception.format_stacktrace(stacktrace)} """)