logger_facade 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 579ce5afc470c007f26871a90e6b724509ee4b4c
4
- data.tar.gz: 60f2891a92be6f1aaca17042ce0f6f45cb5c7630
3
+ metadata.gz: 8392ff8e0a6863d4601fe9931cdb6145aed932c9
4
+ data.tar.gz: 12791d5fb124bbe9f0bbbee15ad913aea775d6b0
5
5
  SHA512:
6
- metadata.gz: 24d1422909da0796ed46700eb1169d4adb9bc5b2dce5b67885a62e059919895819c5e68571ca222ed0574b98ec6313fa73b8ee395adc10094a651ffc27aa7999
7
- data.tar.gz: 65f744d6763a185ee232e654ad40c6189c5b9a3781e6913a6ce6072318e97ba7c09e61c50e54954e0e8c0650819445f58c4e15947cfd9e6092657d157e95b17e
6
+ metadata.gz: e376cd8a463bc43047d154dbf487842876f64acf6f3db9a2c7ccd79e12d8a255cbab8dda4bb29f88019cba6faaee40b8f2c74d8f9e75107de7ae0858aec24e4a
7
+ data.tar.gz: 45d4bcefb121a1e68f5cbacc36b97a7e2392958f68297367a01e6eabc09ec2699a515c8695a205c2dba1b19227c915e94deb0e1f0a2ef9c12612cab38b36ff37
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- logger_facade (0.4.0)
4
+ logger_facade (0.4.1)
5
5
  airbrake (~> 4.0)
6
6
  hashie (~> 3.2)
7
7
  sucker_punch (~> 1.1)
8
- yajl-ruby (~> 1.2)
9
8
 
10
9
  GEM
11
10
  remote: https://rubygems.org/
@@ -55,7 +54,6 @@ GEM
55
54
  celluloid (~> 0.16.0)
56
55
  timers (4.0.1)
57
56
  hitimes
58
- yajl-ruby (1.2.1)
59
57
 
60
58
  PLATFORMS
61
59
  ruby
@@ -22,12 +22,17 @@ module LoggerFacade::Plugins
22
22
 
23
23
  def log(log_level, message, logger, metadata)
24
24
  return unless is_level_active(log_level)
25
+ return if is_dev_env?
25
26
 
26
27
  notify(logger, message, metadata)
27
28
  end
28
29
 
29
30
  private
30
31
 
32
+ def is_dev_env?
33
+ ::Airbrake.configuration.development_environments.include? environment
34
+ end
35
+
31
36
  def notify(logger, message, metadata)
32
37
  return unless valid_config
33
38
 
@@ -1,5 +1,5 @@
1
1
  require 'logger'
2
- require 'yajl'
2
+ require 'json'
3
3
 
4
4
  module LoggerFacade::Plugins
5
5
  class Logstash < Base
@@ -38,7 +38,7 @@ module LoggerFacade::Plugins
38
38
  '@fields' => metadata
39
39
  }
40
40
 
41
- logdevice.write("#{Yajl::Encoder.encode(json)}\n")
41
+ logdevice.write("#{JSON.generate(json)}\n")
42
42
  end
43
43
 
44
44
  class LogDeviceWithRotation < ::Logger::LogDevice
@@ -1,3 +1,3 @@
1
1
  module LoggerFacade
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -35,6 +35,4 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency 'airbrake', '~> 4.0'
36
36
  # sucker punch is used to use airbrake async
37
37
  spec.add_dependency 'sucker_punch', '~> 1.1'
38
- # used by logstash plugin, for better performance
39
- spec.add_dependency 'yajl-ruby', '~> 1.2'
40
38
  end
@@ -11,6 +11,7 @@ describe LoggerFacade::Plugins::Airbrake do
11
11
  subject.configure do |c|
12
12
  c.host = "host.test"
13
13
  c.api_key = "key.test"
14
+ c.development_environments = %w()
14
15
  end
15
16
 
16
17
  end
@@ -58,13 +59,21 @@ describe LoggerFacade::Plugins::Airbrake do
58
59
 
59
60
  end
60
61
 
61
- %w(trace debug info warn error).each do |level|
62
-
62
+ context("logging in error level") do
63
63
 
64
+ context 'on development environment' do
65
+ before :each do
66
+ subject.configure do |c|
67
+ c.development_environments = %w(test)
68
+ end
69
+ end
64
70
 
65
- end
71
+ it("doesn't notify") do
72
+ expect(::Airbrake).not_to receive(:notify_or_ignore)
73
+ subject.error("name", message)
74
+ end
66
75
 
67
- context("logging in error level") do
76
+ end
68
77
 
69
78
  context('with message') do
70
79
 
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  describe LoggerFacade::Plugins::Logstash do
2
4
  include LevelTestHelper
3
5
 
@@ -76,7 +78,7 @@ describe LoggerFacade::Plugins::Logstash do
76
78
  it("writes a valid json") do
77
79
  expect(file).to receive(:write) do |msg|
78
80
  data = nil
79
- expect { data = Yajl::Parser.new.parse(msg) }.not_to raise_exception
81
+ expect { data = JSON.parse(msg) }.not_to raise_exception
80
82
  expect(data).to be
81
83
  end
82
84
  subject.send(severity, logger, message)
@@ -96,7 +98,7 @@ describe LoggerFacade::Plugins::Logstash do
96
98
 
97
99
  it("writes logstash timestamp format") do
98
100
  expect(file).to receive(:write) do |msg|
99
- data = Yajl::Parser.new.parse(msg)
101
+ data = JSON.parse(msg)
100
102
  expect(data["@timestamp"]).to eq(time.iso8601)
101
103
  end
102
104
  subject.send(severity, logger, message)
@@ -104,7 +106,7 @@ describe LoggerFacade::Plugins::Logstash do
104
106
 
105
107
  it("uses metadata timestamp") do
106
108
  expect(file).to receive(:write) do |msg|
107
- data = Yajl::Parser.new.parse(msg)
109
+ data = JSON.parse(msg)
108
110
  expect(data["@timestamp"]).to eq(ts.iso8601)
109
111
  end
110
112
  subject.send(severity, logger, message, metadata: metadata)
@@ -112,7 +114,7 @@ describe LoggerFacade::Plugins::Logstash do
112
114
 
113
115
  it("doesn't write field timestamp") do
114
116
  expect(file).to receive(:write) do |msg|
115
- data = Yajl::Parser.new.parse(msg)["@fields"]
117
+ data = JSON.parse(msg)["@fields"]
116
118
  expect(data["timestamp"]).to be_nil
117
119
  end
118
120
  subject.send(severity, logger, message, metadata: metadata)
@@ -121,7 +123,7 @@ describe LoggerFacade::Plugins::Logstash do
121
123
 
122
124
  it("writes fields") do
123
125
  expect(file).to receive(:write) do |msg|
124
- data = Yajl::Parser.new.parse(msg)
126
+ data = JSON.parse(msg)
125
127
  expect(data["@fields"]).to be
126
128
  end
127
129
  subject.send(severity, logger, message)
@@ -129,7 +131,7 @@ describe LoggerFacade::Plugins::Logstash do
129
131
 
130
132
  it("writes severity") do
131
133
  expect(file).to receive(:write) do |msg|
132
- data = Yajl::Parser.new.parse(msg)["@fields"]
134
+ data = JSON.parse(msg)["@fields"]
133
135
  expect(data["severity"]).to eq(severity.to_s)
134
136
  end
135
137
  subject.send(severity, logger, message)
@@ -137,7 +139,7 @@ describe LoggerFacade::Plugins::Logstash do
137
139
 
138
140
  it("writes logger") do
139
141
  expect(file).to receive(:write) do |msg|
140
- data = Yajl::Parser.new.parse(msg)["@fields"]
142
+ data = JSON.parse(msg)["@fields"]
141
143
  expect(data["logger"]).to eq(logger)
142
144
  end
143
145
  subject.send(severity, logger, message)
@@ -145,7 +147,7 @@ describe LoggerFacade::Plugins::Logstash do
145
147
 
146
148
  it("writes message") do
147
149
  expect(file).to receive(:write) do |msg|
148
- data = Yajl::Parser.new.parse(msg)["@fields"]
150
+ data = JSON.parse(msg)["@fields"]
149
151
  expect(data["message"]).to eq(message)
150
152
  end
151
153
  subject.send(severity, logger, message)
@@ -154,7 +156,7 @@ describe LoggerFacade::Plugins::Logstash do
154
156
  it("writes other metadata fields") do
155
157
  metadata = { context: true }
156
158
  expect(file).to receive(:write) do |msg|
157
- data = Yajl::Parser.new.parse(msg)["@fields"]
159
+ data = JSON.parse(msg)["@fields"]
158
160
  expect(data["context"]).to eq(true)
159
161
  end
160
162
  subject.send(severity, logger, message, metadata: metadata)
@@ -165,7 +167,7 @@ describe LoggerFacade::Plugins::Logstash do
165
167
  it('writes the exception message') do
166
168
  error = Exception.new('test log')
167
169
  expect(file).to receive(:write) do |msg|
168
- data = Yajl::Parser.new.parse(msg)["@fields"]
170
+ data = JSON.parse(msg)["@fields"]
169
171
  expect(data["message"]).to eq("test log")
170
172
  end
171
173
  subject.send(severity, logger, error)
@@ -175,7 +177,7 @@ describe LoggerFacade::Plugins::Logstash do
175
177
  error = Exception.new('test log')
176
178
  error.set_backtrace "stacktrace"
177
179
  expect(file).to receive(:write) do |msg|
178
- data = Yajl::Parser.new.parse(msg)["@fields"]
180
+ data = JSON.parse(msg)["@fields"]
179
181
  expect(data["backtrace"]).to eq(error.backtrace)
180
182
  end
181
183
  subject.send(severity, logger, error)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logger_facade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Januário
@@ -164,20 +164,6 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '1.1'
167
- - !ruby/object:Gem::Dependency
168
- name: yajl-ruby
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '1.2'
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '1.2'
181
167
  description: |-
182
168
  Simple class library to work as logger facade.
183
169
  This simple logger facade allows you to hook plugins to execute logging.