Skip to content

Commit

Permalink
Add runtime environment value to Sentry tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrián Quintás committed May 22, 2018
1 parent a608c3b commit 55eed96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/logger/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ defmodule ServerUtils.SentryLogger do
Returns `:ok` or an `{:error, reason}` tuple.
Returns a [Task](https://hexdocs.pm/elixir/Task.html#content) struct is Sentry is **enabled**.
Returns a [Task](https://hexdocs.pm/elixir/Task.html#content) struct if Sentry is **enabled**.
"""
@spec warn(String.t()) :: atom() | Task.t()
def warn(message) do
if System.get_env("DISABLE_SENTRY") do
Logger.warn(fn -> message end)
else
opts = [
environment: System.get_env("ENVIRONMENT"),
tags: %{
environment: System.get_env("ENVIRONMENT")
},
level: "warning"
]

Expand All @@ -61,15 +63,17 @@ defmodule ServerUtils.SentryLogger do
Returns `:ok` or an `{:error, reason}` tuple if Sentry is **disabled**.
Returns a [Task](https://hexdocs.pm/elixir/Task.html#content) struct is Sentry is **enabled**.
Returns a [Task](https://hexdocs.pm/elixir/Task.html#content) struct if Sentry is **enabled**.
"""
@spec error(String.t()) :: atom() | Task.t()
def error(message) do
if System.get_env("DISABLE_SENTRY") do
Logger.error(fn -> message end)
else
opts = [
environment: System.get_env("ENVIRONMENT"),
tags: %{
environment: System.get_env("ENVIRONMENT")
},
level: "error"
]

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule ServerUtils.Mixfile do
@moduledoc false
use Mix.Project

@version "0.2.3"
@version "0.2.4"

def project do
[
Expand Down

0 comments on commit 55eed96

Please sign in to comment.