Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): supports elixir/erlang 1.14/24 #8

Merged
merged 7 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading