Skip to content

Commit

Permalink
reporters
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Aug 23, 2024
1 parent 195ee02 commit 96c5684
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 17 additions & 2 deletions lib/tower.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Tower do
It tries to do one job well, **handle** error **events** in an elixir application
**and inform** configured **reporters** (one or many) about these events.
defmodule MyReporter do
defmodule MyApp.ErrorReporter do
@behaviour Tower.Reporter
@impl true
Expand All @@ -14,14 +14,29 @@ defmodule Tower do
end
end
Application.put_env(:tower, :reporters, [MyReporter])
Application.put_env(:tower, :reporters, [MyApp.ErrorReporter])
Tower.attach()
`Tower.attach/0` will be responsible for registering the necessary handlers in your application
so that any uncaught exception, uncaught throw or abnormal process exit is handled by Tower and
passed along to reporters.
## Reporters
You can either write your own reporter or use any amount of the following reporters (separate packages):
* [tower_email](https://hex.pm/packages/tower_email) ([`TowerEmail.Reporter`](https://hexdocs.pm/tower_email/TowerEmail.Reporter.html))
* [tower_rollbar](https://hex.pm/packages/tower_rollbar) ([`TowerRollbar.Reporter`](https://hexdocs.pm/tower_rollbar/TowerRollbar.Reporter.html))
* [tower_slack](https://hex.pm/packages/tower_slack) ([`TowerSlack.Reporter`](https://hexdocs.pm/tower_slack/TowerSlack.Reporter.html))
In case you use any of the above reporters, you don't need to explicitly include `tower` package as a dependency.
It should be a transitive dependency of any of the above reporters.
### Writing a custom reporter yourself?
Check out `Tower.Reporter` behvaiour.
## Manual handling
If either, for whatever reason an exception condition is not reaching Tower handling, or you just
Expand Down
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ defmodule Tower.MixProject do
[
main: "Tower",
extras: [
"README.md": [title: "README"],
"CHANGELOG.md": [title: "Changelog"]
]
]
Expand Down

0 comments on commit 96c5684

Please sign in to comment.