Skip to content

Commit 267f08f

Browse files
committed
Refactor logs
1 parent 82d8c04 commit 267f08f

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

lib/membrane/core/callback_handler.ex

+2-22
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ defmodule Membrane.Core.CallbackHandler do
185185
Error handling actions returned by callback #{inspect(state.module)}.#{callback}
186186
""")
187187

188-
log_debug_orginal_error(actions, e, __STACKTRACE__)
189-
190188
reraise e, __STACKTRACE__
191189
end
192190

@@ -197,32 +195,14 @@ defmodule Membrane.Core.CallbackHandler do
197195
rescue
198196
e ->
199197
Membrane.Logger.error("""
200-
Error handling action #{inspect(action)} returned by callback #{inspect(state.module)}.#{callback}
198+
Error handling action returned by callback #{inspect(state.module)}.#{callback}.
199+
Action: #{inspect(action, pretty: true)}
201200
""")
202201

203-
log_debug_orginal_error(action, e, __STACKTRACE__)
204-
205202
reraise e, __STACKTRACE__
206203
end
207204
end)
208205

209206
handler_module.handle_end_of_actions(state)
210207
end
211-
212-
# We log it, because sometimes, for some reason, crashing process doesn't cause
213-
# printing error logs on stderr, so this debug log allows us to get some info
214-
# about what happened in case of process crash
215-
defp log_debug_orginal_error(action_or_actions, error, stacktrace) do
216-
action_or_actions =
217-
if(is_list(action_or_actions), do: "actions ", else: "action ") <>
218-
inspect(action_or_actions, limit: :infinity)
219-
220-
Membrane.Logger.debug("""
221-
Error while handling #{action_or_actions}
222-
223-
Orginal error:
224-
#{inspect(error, pretty: true, limit: :infinity)}
225-
#{Exception.format_stacktrace(stacktrace)}
226-
""")
227-
end
228208
end

lib/membrane/core/macros.ex

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
defmodule Membrane.Core.Macros do
22
@moduledoc false
33

4+
# For some reason GenServer processes sometimes don't print logs about crash, so
5+
# we add this macro, to ensure that error logs wil be always logged
46
defmacro log_on_error(do: code) do
57
quote do
68
try do

0 commit comments

Comments
 (0)