gray_logger 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gray_logger/configuration.rb +2 -2
- data/lib/gray_logger/logger.rb +7 -0
- data/lib/gray_logger/proxy.rb +15 -4
- data/lib/gray_logger/rack.rb +1 -1
- metadata +3 -3
@@ -2,7 +2,7 @@ module GrayLogger
|
|
2
2
|
class Configuration
|
3
3
|
include ::GrayLogger::Support
|
4
4
|
|
5
|
-
attr_accessor :host, :port, :size, :automatic_logging, :options
|
5
|
+
attr_accessor :host, :port, :size, :automatic_logging, :logger_level, :options
|
6
6
|
def initialize(configuration_hash)
|
7
7
|
defaults = {
|
8
8
|
:size => "WAN",
|
@@ -12,7 +12,7 @@ module GrayLogger
|
|
12
12
|
config = symbolize_keys(configuration_hash)
|
13
13
|
config = defaults.merge(config)
|
14
14
|
|
15
|
-
[:host, :port, :size, :automatic_logging].each do |method|
|
15
|
+
[:host, :port, :size, :automatic_logging, :logger_level].each do |method|
|
16
16
|
send("#{method}=", config.delete(method))
|
17
17
|
end
|
18
18
|
self.options = config
|
data/lib/gray_logger/logger.rb
CHANGED
data/lib/gray_logger/proxy.rb
CHANGED
@@ -1,17 +1,25 @@
|
|
1
1
|
module GrayLogger
|
2
2
|
class Proxy
|
3
|
-
attr_accessor :proxied_logger
|
3
|
+
attr_accessor :proxied_logger
|
4
4
|
|
5
5
|
def initialize(attributes={})
|
6
6
|
self.proxied_logger = attributes[:proxied_logger]
|
7
|
-
|
7
|
+
@gray_logger = attributes[:gray_logger]
|
8
|
+
end
|
9
|
+
|
10
|
+
def gray_logger
|
11
|
+
if ::GrayLogger.configuration
|
12
|
+
@gray_logger ||= ::GrayLogger::Logger.new(::GrayLogger.configuration.dup)
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
# def debug(*args)
|
11
17
|
# if proxied_logger.nil?
|
12
18
|
# gray_logger.send(:debug, *args)
|
13
19
|
# else
|
14
|
-
#
|
20
|
+
# if !gray_logger.nil? && gray_logger.debug?
|
21
|
+
# gray_logger.after_request_log.append_to(:log_file, "[debug] #{args[0]}")
|
22
|
+
# end
|
15
23
|
# proxied_logger.send(:debug, *args)
|
16
24
|
# end
|
17
25
|
# end
|
@@ -21,7 +29,10 @@ module GrayLogger
|
|
21
29
|
if proxied_logger.nil?
|
22
30
|
gray_logger.send(:#{const.downcase}, *args)
|
23
31
|
else
|
24
|
-
gray_logger.
|
32
|
+
if !gray_logger.nil? && gray_logger.#{const.downcase}?
|
33
|
+
puts "level: #{const.downcase}"
|
34
|
+
gray_logger.after_request_log.append_to(:log_file, "[#{const.downcase}] \#{args[0]}")
|
35
|
+
end
|
25
36
|
proxied_logger.send(:#{const.downcase}, *args)
|
26
37
|
end
|
27
38
|
end
|
data/lib/gray_logger/rack.rb
CHANGED
@@ -8,13 +8,13 @@ module Rack
|
|
8
8
|
|
9
9
|
def initialize(app)
|
10
10
|
@app = app
|
11
|
-
::GrayLogger.proxy.gray_logger = ::GrayLogger::Logger.new(::GrayLogger.configuration.dup)
|
12
11
|
end
|
13
12
|
|
14
13
|
def call(env)
|
15
14
|
env["rack.gray_logger.proxy"] = ::GrayLogger.proxy
|
16
15
|
gray_logger = ::GrayLogger.proxy.gray_logger
|
17
16
|
begin
|
17
|
+
gray_logger.reset!
|
18
18
|
status, headers, body = @app.call(env)
|
19
19
|
rescue => e
|
20
20
|
gray_logger.log_exception(e) if gray_logger.automatic_logging?
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gray_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 53
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 11
|
9
|
-
-
|
10
|
-
version: 0.11.
|
9
|
+
- 3
|
10
|
+
version: 0.11.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Behr
|