Skip to content

Commit

Permalink
build(deps): supports elixir/erlang 1.14/24 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy authored Jun 6, 2024
1 parent dcb6b4a commit 02b38d6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
lint: true
- elixir: '1.15'
erlang: '25.3.2.12'
- elixir: '1.14'
erlang: '24.3.4.17'
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
Expand Down
51 changes: 51 additions & 0 deletions lib/tower/logger_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ defmodule Tower.LoggerHandler do
:ok
end

# elixir 1.15+
def log(%{level: :error, meta: %{crash_reason: {exception, stacktrace}} = meta}, _config)
when is_exception(exception) and is_list(stacktrace) do
IO.puts("[Tower.LoggerHandler] EXCEPTION #{inspect(exception)}")

Tower.report_exception(exception, stacktrace, meta)
end

# elixir 1.15+
def log(
%{level: :error, meta: %{crash_reason: {{:nocatch, reason}, stacktrace}} = meta},
_config
Expand All @@ -41,13 +43,62 @@ defmodule Tower.LoggerHandler do
Tower.report(:nocatch, reason, stacktrace, meta)
end

# elixir 1.15+
def log(%{level: :error, meta: %{crash_reason: {exit_reason, stacktrace}} = meta}, _config)
when is_list(stacktrace) do
IO.puts("[Tower.LoggerHandler] EXIT #{inspect(exit_reason)}")

Tower.report(:exit, exit_reason, stacktrace, meta)
end

# elixir 1.14
def log(
%{
level: :error,
msg: {:report, %{report: %{reason: {exception, stacktrace}}}},
meta: meta
},
_config
)
when is_exception(exception) and is_list(stacktrace) do
Tower.report_exception(exception, stacktrace, meta)
end

# elixir 1.14
def log(
%{
level: :error,
msg: {:report, %{report: %{reason: {{:nocatch, reason}, stacktrace}}}},
meta: meta
},
_config
)
when is_list(stacktrace) do
Tower.report(:nocatch, reason, stacktrace, meta)
end

# elixir 1.14
def log(
%{
level: :error,
msg: {:report, %{report: %{reason: {reason, stacktrace}}}},
meta: meta
},
_config
)
when is_list(stacktrace) do
case Exception.normalize(:error, reason) do
%ErlangError{} ->
Tower.report(:exit, reason, stacktrace, meta)

e when is_exception(e) ->
Tower.report_exception(e, stacktrace, meta)

_ ->
Tower.report(:exit, reason, stacktrace, meta)
end
end

def log(log_event, _config) do
IO.puts(
"[Tower.LoggerHandler] UNHANDLED LOG EVENT log_event=#{inspect(log_event, pretty: true)}"
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule Tower.MixProject do
app: :tower,
description: @description,
version: @version,
elixir: "~> 1.15",
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
deps: deps(),
package: package(),
Expand Down

0 comments on commit 02b38d6

Please sign in to comment.