vx-lib-logger 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb07f0c4435d8c25f0889f2fbaefb33e30a8590a
4
- data.tar.gz: 1aab7964ee444246809bd9756d1cf5d05c70ad9b
3
+ metadata.gz: d75d4c71acfbd5d160ee7383591acea877911cfa
4
+ data.tar.gz: e72ad9013278de2e4494e59fc39ebdc1a1e58d2c
5
5
  SHA512:
6
- metadata.gz: 7a896d173fabe44932b75e794a5156e2da947a7426c5010a5df476d4fa83bd7f123923ea0c2402ee02850555e9be9bfba3858898b3a722e17f92f86e51bce326
7
- data.tar.gz: eafa5f2d32ff67243737e3c627efd4c9cb95a3d3819afff6e1caede91c2ada0470520b85b1092f1cbaccc6e2d2aa314dc155b98a244189856a69e6b2c7cfab62
6
+ metadata.gz: db9e744c0eb69e480cf4322134dbb1ea3e9d5c4db761025a2a4cc9daef458ee61a0bfa247755270fe6e42334efeb51f6799ce556553317d0f56af1527cd368fe
7
+ data.tar.gz: f28c5064bc548ad5cc7a1e5b2006b9e889551fa17f8449fc28d848d95703e4e07b37137e1e72ba2f62856080809d5340707e804d898d9d8aecfde8a9924da664
data/lib/vx/lib/logger.rb CHANGED
@@ -4,13 +4,20 @@ require File.expand_path("../logger/version", __FILE__)
4
4
  module Vx ; module Lib
5
5
  module Logger
6
6
 
7
- autoload :Instance, File.expand_path("../logger/instance", __FILE__)
8
- autoload :JsonFormatter, File.expand_path("../logger/json_formatter", __FILE__)
9
- autoload :Instrumentations, File.expand_path("../logger/instrumentations", __FILE__)
7
+ autoload :Instance, File.expand_path("../logger/instance", __FILE__)
8
+ autoload :JsonFormatter, File.expand_path("../logger/json_formatter", __FILE__)
9
+ autoload :Instrumentations, File.expand_path("../logger/instrumentations", __FILE__)
10
+ autoload :HandleExceptions, File.expand_path("../logger/handle_exceptions", __FILE__)
11
+
12
+ @@default = Instance.new(STDOUT)
10
13
 
11
14
  def self.get(io, options)
12
15
  Instance.new(io, options)
13
16
  end
14
17
 
18
+ def default
19
+ @@default
20
+ end
21
+
15
22
  end
16
23
  end ; end
@@ -0,0 +1,49 @@
1
+ module Vx ; module Lib ; module Logger
2
+ module Rack
3
+
4
+ HandleExceptions = Struct.new(:app) do
5
+
6
+ IGNORED_EXCEPTIONS = %w{
7
+ ActionController::RoutingError
8
+ }
9
+
10
+ def clean_env(env)
11
+ env = env.select{|k,v| k !~ /^(action_dispatch|puma|session|rack\.session|action_controller)/ }
12
+ env['HTTP_COOKIE'] &&= env['HTTP_COOKIE'].scan(/.{80}/).join("\n")
13
+ env
14
+ end
15
+
16
+ def notify(exception, env)
17
+ unless ignore?(exception)
18
+ Lib::Logger.default.error(
19
+ "Unhandled exception",
20
+ clean_env(env).merge(exception: exception)
21
+ )
22
+ end
23
+ end
24
+
25
+ def call(env)
26
+ begin
27
+ response = app.call(env)
28
+ rescue Exception => ex
29
+ notify ex, env
30
+ end
31
+
32
+ if ex = framework_exception(env)
33
+ notify ex, env
34
+ end
35
+
36
+ response
37
+ end
38
+
39
+ def framework_exception(env)
40
+ env['rack.exception'] || env['action_dispatch.exception']
41
+ end
42
+
43
+ def ignore?(ex)
44
+ IGNORED_EXCEPTIONS.include? ex.class.name
45
+ end
46
+
47
+ end
48
+ end
49
+ end ; end ; end
@@ -1,7 +1,7 @@
1
1
  module Vx
2
2
  module Lib
3
3
  module Logger
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-lib-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -65,6 +65,7 @@ files:
65
65
  - README.md
66
66
  - Rakefile
67
67
  - lib/vx/lib/logger.rb
68
+ - lib/vx/lib/logger/handle_exceptions.rb
68
69
  - lib/vx/lib/logger/instance.rb
69
70
  - lib/vx/lib/logger/instrumentations.rb
70
71
  - lib/vx/lib/logger/json_formatter.rb