Skip to content

Commit

Permalink
feat: support reporting structured log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Jul 12, 2024
1 parent 41f6e3c commit f6ee5d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/tower_rollbar/reporter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ defmodule TowerRollbar.Reporter do
end

@impl true
def report_message(level, message, _metadata \\ %{}) when is_binary(message) do
def report_message(level, message, metadata \\ %{})

def report_message(level, message, _metadata) when is_binary(message) do
if enabled?() do
Rollbar.Client.post(
"/item",
Expand All @@ -52,6 +54,10 @@ defmodule TowerRollbar.Reporter do
end
end

def report_message(level, message, metadata) when is_list(message) or is_map(message) do
report_message(level, inspect(message), metadata)
end

defp plug_conn(%{conn: conn}) do
conn
end
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"plug": {:hex, :plug, "1.16.1", "40c74619c12f82736d2214557dedec2e9762029b2438d6d175c5074c933edc9d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a13ff6b9006b03d7e33874945b2755253841b238c34071ed85b0e86057f8cddc"},
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"tower": {:git, "https://github.com/mimiquate/tower.git", "24ba0465e334ef71e22a242ca007324fc1e07463", []},
"tower": {:git, "https://github.com/mimiquate/tower.git", "3b0d3b7ec1c1bfa1bc86a84ce19ff5a9b2112b50", []},
}

0 comments on commit f6ee5d5

Please sign in to comment.