Packages
raygun
0.0.35
0.4.0
0.3.2
0.3.1
0.3.0
0.2.0
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.45
0.0.44
0.0.43
0.0.42
0.0.41
0.0.40
0.0.39
0.0.38
0.0.37
0.0.36
0.0.35
0.0.34
0.0.33
0.0.32
0.0.31
0.0.30
0.0.29
0.0.28
0.0.27
0.0.26
0.0.25
0.0.24
0.0.23
0.0.22
0.0.21
0.0.20
0.0.19
0.0.18
0.0.17
0.0.16
0.0.15
0.0.14
0.0.13
0.0.12
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
Send errors in your application to Raygun. Raygun captures all your application errors in one place. It can be used as a Plug, via Logger and/or programmatically.
Current section
57 Versions
Jump to
Current section
57 Versions
Compare versions
3
files changed
+24
additions
-6
deletions
| @@ -28,4 +28,4 @@ | |
| 28 28 | [{<<"app">>,<<"timex">>}, |
| 29 29 | {<<"optional">>,false}, |
| 30 30 | {<<"requirement">>,<<"~> 0.19.2">>}]}]}. |
| 31 | - {<<"version">>,<<"0.0.34">>}. |
| 31 | + {<<"version">>,<<"0.0.35">>}. |
| @@ -1,14 +1,32 @@ | |
| 1 | + defmodule Raygun.Plug.State do |
| 2 | + def start_link do |
| 3 | + Agent.start_link(fn -> nil end, name: __MODULE__) |
| 4 | + end |
| 5 | + |
| 6 | + def start_and_set(value) do |
| 7 | + start_link |
| 8 | + set(value) |
| 9 | + end |
| 10 | + |
| 11 | + def set(value) do |
| 12 | + Agent.update(__MODULE__, fn (x) -> value end) |
| 13 | + end |
| 14 | + |
| 15 | + def get do |
| 16 | + Agent.get(__MODULE__, fn(x) -> x end) |
| 17 | + end |
| 18 | + |
| 19 | + end |
| 20 | + |
| 1 21 | defmodule Raygun.Plug do |
| 2 22 | @moduledoc """ |
| 3 23 | This plug is designed to wrap calls in a router (commonly in Phoenix) so that |
| 4 24 | any exceptions will be sent to Raygun. |
| 5 25 | """ |
| 6 26 | |
| 7 | - @user_fn Agent.start_link(fn -> nil end) |
| 8 | - |
| 9 27 | defmacro __using__(env) do |
| 10 | - Agent.update(@user_fn, fn(current) -> env.user end) |
| 11 28 | quote location: :keep do |
| 29 | + Raygun.Plug.State.start_and_set(env.user) |
| 12 30 | @before_compile Raygun.Plug |
| 13 31 | end |
| 14 32 | end |
| @@ -26,7 +44,7 @@ defmodule Raygun.Plug do | |
| 26 44 | rescue |
| 27 45 | exception -> |
| 28 46 | stacktrace = System.stacktrace |
| 29 | - user = Agent.get(@user_fn, fn (val) -> val end) |
| 47 | + user = Raygun.Plug.State.get() |
| 30 48 | user = if user, do: user.(conn) |
| 31 49 | IO.puts "user is #{user}" |
| 32 50 | Raygun.report_plug(conn, stacktrace, exception, env: Atom.to_string(Mix.env), user: user) |
| @@ -3,7 +3,7 @@ defmodule Raygun.Mixfile do | |
| 3 3 | |
| 4 4 | def project do |
| 5 5 | [app: :raygun, |
| 6 | - version: "0.0.34", |
| 6 | + version: "0.0.35", |
| 7 7 | elixir: "~> 1.0", |
| 8 8 | source_url: "https://github.com/cobenian/raygun", |
| 9 9 | build_embedded: Mix.env == :prod, |