Skip to content

Commit

Permalink
fix: support Elixir 1.17 (#575)
Browse files Browse the repository at this point in the history
* Test Elixir 1.14-1.17

https://hexdocs.pm/elixir/1.17.3/compatibility-and-deprecations.html

* Support Elixir 1.17 logger error messages

Elixir 1.17 made some changes to error logging that affected the pattern
matching in our `gen_event` handler. This supports the new and the old
events when extracting details for the error context.

Related:

https://github.com/elixir-lang/elixir/releases/tag/v1.7.0
https://www.infoq.com/news/2018/08/elixir-1.7-improvements/
https://www.erlang.org/doc/apps/stdlib/gen_event.html
https://hexdocs.pm/logger/Logger.html

* Update .github/workflows/elixir.yml

---------

Co-authored-by: Parker Selbert <[email protected]>
  • Loading branch information
joshuap and sorentwo authored Dec 19, 2024
1 parent bca38d9 commit 785ea1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ jobs:
matrix:
include:
- pair:
elixir: '1.11'
otp: '21.3'
elixir: '1.14'
otp: '23.3'
- pair:
elixir: '1.15'
otp: '26.0'
- pair:
elixir: '1.17'
otp: '27.0'
lint: lint

runs-on: ubuntu-20.04
Expand Down
12 changes: 12 additions & 0 deletions lib/honeybadger/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,26 @@ defmodule Honeybadger.Logger do
|> Map.new()
end

# Elixir < 1.17
defp extract_details([["GenServer ", _pid, _res, _stack, _last, _, _, last], _, state]) do
%{last_message: last, state: state}
end

# Elixir < 1.17
defp extract_details([[":gen_event handler ", name, _, _, _, _stack, _last, last], _, state]) do
%{name: name, last_message: last, state: state}
end

# Elixir >= 1.17
defp extract_details([["GenServer ", _pid, _res, _stack, _last, _, _, _, last], _, state]) do
%{last_message: last, state: state}
end

# Elixir >= 1.17
defp extract_details([[":gen_event handler ", name, _, _, _, _stack, _, _last, last], _, state]) do
%{name: name, last_message: last, state: state}
end

defp extract_details(["Process ", pid | _]) do
%{name: pid}
end
Expand Down

0 comments on commit 785ea1c

Please sign in to comment.