Skip to content

Commit 1d7e50f

Browse files
Merge pull request #196 from getsentry/remove-use-error-logger
remove use_error_logger configuration
2 parents 2b689b8 + 588054e commit 1d7e50f

File tree

5 files changed

+43
-26
lines changed

5 files changed

+43
-26
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,22 @@ use Sentry.Plug
4747

4848
### Capture All Exceptions
4949

50-
This library comes with an extension to capture all Error messages that the Plug handler might not. Simply set `use_error_logger` to true.
50+
This library comes with an extension to capture all error messages that the Plug handler might not. This is based on the Erlang [error_logger](http://erlang.org/doc/man/error_logger.html).
5151

52-
This is based on the Erlang [error_logger](http://erlang.org/doc/man/error_logger.html).
52+
To set this up, add `:ok = :error_logger.add_report_handler(Sentry.Logger)` to your application's start function. Example:
5353

5454
```elixir
55-
config :sentry,
56-
use_error_logger: true
55+
def start(_type, _opts) do
56+
children = [
57+
supervisor(Task.Supervisor, [[name: Sentry.TaskSupervisor]]),
58+
:hackney_pool.child_spec(Sentry.Client.hackney_pool_name(), [timeout: Config.hackney_timeout(), max_connections: Config.max_hackney_connections()])
59+
]
60+
opts = [strategy: :one_for_one, name: Sentry.Supervisor]
61+
62+
:ok = :error_logger.add_report_handler(Sentry.Logger)
63+
64+
Supervisor.start_link(children, opts)
65+
end
5766
```
5867

5968
## Configuration
@@ -66,7 +75,6 @@ config :sentry,
6675
| `tags` | False | `%{}` | |
6776
| `release` | False | None | |
6877
| `server_name` | False | None | |
69-
| `use_error_logger` | False | False | |
7078
| `client` | False | `Sentry.Client` | If you need different functionality for the HTTP client, you can define your own module that implements the `Sentry.HTTPClient` behaviour and set `client` to that module |
7179
| `hackney_opts` | False | `[pool: :sentry_pool]` | |
7280
| `hackney_pool_max_connections` | False | 50 | |

docs/config.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ If using an environment with Plug or Phoenix add the following to your router:
1717
use Plug.ErrorHandler
1818
use Sentry.Plug
1919
20+
If you'd like to capture errors from separate processes like `Task` that may crash, add the line ``:ok = :error_logger.add_report_handler(Sentry.Logger)`` to your application's start function:
21+
22+
.. code-block:: elixir
23+
def start(_type, _opts) do
24+
children = [
25+
supervisor(Task.Supervisor, [[name: Sentry.TaskSupervisor]]),
26+
:hackney_pool.child_spec(Sentry.Client.hackney_pool_name(), [timeout: Config.hackney_timeout(), max_connections: Config.max_hackney_connections()])
27+
]
28+
opts = [strategy: :one_for_one, name: Sentry.Supervisor]
29+
30+
:ok = :error_logger.add_report_handler(Sentry.Logger)
31+
32+
Supervisor.start_link(children, opts)
33+
end
34+
2035
Required settings
2136
------------------
2237

@@ -55,11 +70,6 @@ Optional settings
5570

5671
The name of the server to send with each report. This defaults to nothing.
5772

58-
.. describe:: use_error_logger
59-
60-
Set this to true if you want to capture all exceptions that occur even outside of a request cycle. This
61-
defaults to false.
62-
6373
.. describe:: client
6474

6575
If you need different functionality for the HTTP client, you can define your own module that implements the `Sentry.HTTPClient` behaviour and set `client` to that module.

lib/sentry.ex

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ defmodule Sentry do
9191
See `Sentry.Logger`
9292
"""
9393

94-
@use_error_logger Config.use_error_logger()
95-
9694
@type task :: {:ok, Task.t} | :error | :excluded | :ignored
9795

9896
def start(_type, _opts) do
@@ -102,10 +100,6 @@ defmodule Sentry do
102100
]
103101
opts = [strategy: :one_for_one, name: Sentry.Supervisor]
104102

105-
if @use_error_logger do
106-
:error_logger.add_report_handler(Sentry.Logger)
107-
end
108-
109103
Supervisor.start_link(children, opts)
110104
end
111105

lib/sentry/config.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ defmodule Sentry.Config do
5555
get_config(:client, default: Sentry.Client, check_dsn: false)
5656
end
5757

58-
def use_error_logger do
59-
get_config(:use_error_logger, default: false, check_dsn: false)
60-
end
61-
6258
def root_source_code_path do
6359
path = get_config(:root_source_code_path)
6460

lib/sentry/logger.ex

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
defmodule Sentry.Logger do
22
require Logger
33
@moduledoc """
4-
Use this if you'd like to capture all Error messages that the Plug handler might not. Simply set `use_error_logger` to true.
4+
This is based on the Erlang [error_logger](http://erlang.org/doc/man/error_logger.html).
55
6-
This is based on the Erlang [error_logger](http://erlang.org/doc/man/error_logger.html).
6+
To set this up, add `:ok = :error_logger.add_report_handler(Sentry.Logger)` to your application's start function. Example:
77
8-
```elixir
9-
config :sentry,
10-
use_error_logger: true
11-
```
8+
```elixir
9+
def start(_type, _opts) do
10+
children = [
11+
supervisor(Task.Supervisor, [[name: Sentry.TaskSupervisor]]),
12+
:hackney_pool.child_spec(Sentry.Client.hackney_pool_name(), [timeout: Config.hackney_timeout(), max_connections: Config.max_hackney_connections()])
13+
]
14+
opts = [strategy: :one_for_one, name: Sentry.Supervisor]
15+
16+
:ok = :error_logger.add_report_handler(Sentry.Logger)
17+
18+
Supervisor.start_link(children, opts)
19+
end
20+
```
1221
"""
1322

1423
use GenEvent

0 commit comments

Comments
 (0)