Skip to content

Commit

Permalink
ignore errors from slack_logger_backend - leads to recursive error loop
Browse files Browse the repository at this point in the history
  • Loading branch information
whossname committed Jun 21, 2022
1 parent b7b6391 commit 54e5e48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/slack_logger_backend/consumer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule SlackLoggerBackend.Consumer do
"""
use GenStage
alias SlackLoggerBackend.{Formatter, Pool}
require Logger

@doc false
def start_link([max_demand, min_demand]) do
Expand Down Expand Up @@ -32,7 +33,13 @@ defmodule SlackLoggerBackend.Consumer do
end

defp process_events([json | events], state) do
Pool.post(json)
try do
Pool.post(json)
rescue
_ ->
Logger.error("slack_logger_backend could no send event: #{json}")
end

process_events(events, state)
end
end
4 changes: 3 additions & 1 deletion lib/slack_logger_backend/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ defmodule SlackLoggerBackend.Logger do

@doc false
def handle_event({level, _pid, {_, message, _timestamp, detail}}, %{levels: levels} = state) do
if level in levels do
app = detail[:application]

if level in levels and app != :slack_logger_backend do
do_handle_event(level, message, detail, state.opts)
end

Expand Down

0 comments on commit 54e5e48

Please sign in to comment.