green_log 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: a3c301ce67ee757ddf2093b93fc973ff46ad005f2ea7e8da3e693ca01a6c7444
4
- data.tar.gz: 0ec5551c9554ec465acfd815f4a95514f8dbf48529427a0187d51b02657e2671
3
+ metadata.gz: 505b570d0cf686dae462b48c5480e527d039e8e8bdf334e400a33a88da50cd77
4
+ data.tar.gz: 75104ff8e40ae40a08913433591247f39788053da332b7f9485b386af1f1787a
5
5
  SHA512:
6
- metadata.gz: 889da34f831f8d7b95bb79343b6905f88d0ffde04a308773ec6775ed70f2b7ffd8668f7eb9c0c8b6ec5fc4d7a2ffbbc6ff59ccecbbdac34fec6ac598c35bba0b
7
- data.tar.gz: f72a8e18d791b8d57a6a413d40c870c7dfb3b34414dc6e00862972acf927ef34d3520676cc973f2fdb7c29f0d92b9d15a69fed230d257b8f19c069b9f8523e7e
6
+ metadata.gz: df89efb0360c12c546715c5e99caeae2f305ddbee4e9200eba8ea6badec30163a2932d9ffdf12b596f8aa0cb28e54bf3940e163730833c768626c42db8fc0094
7
+ data.tar.gz: 2e661586a2ffcb6aa851a0d87e1b38e96966d394e5a69b5dbc1a56969b49baa8ce7cf38e9433c5b2411ec70f3c4fb15bf0d45640ed1c9d3432277cd4318086c0
data/README.md CHANGED
@@ -140,6 +140,14 @@ Logs go to STDOUT by default; specify `dest` to override, e.g.
140
140
  logger = GreenLog::Logger.build(dest: STDERR)
141
141
  ```
142
142
 
143
+ ### Null logger
144
+
145
+ `GreenLog::Logger.null` returns a "null object" Logger, which routes log entries to `/dev/null`.
146
+
147
+ ```ruby
148
+ logger = GreenLog::Logger.null
149
+ ```
150
+
143
151
  ### Filtering by log severity
144
152
 
145
153
  By default all log entries will result in output. You can add a severity-threshold to avoid emitting debug-level log messages, e.g.
@@ -185,6 +193,18 @@ legacy_logger.warn("Old skool")
185
193
  # outputs: W -- Old skool
186
194
  ```
187
195
 
196
+ ### Rack request-logging
197
+
198
+ GreenLog bundles a Rack middleware - an alternative to [`Rack::CommonLogger`](https://www.rubydoc.info/gems/rack/Rack/CommonLogger) - that generates structured HTTP access logs:
199
+
200
+ ```ruby
201
+ require "green_log"
202
+ require "green_log/rack/request_logging"
203
+
204
+ logger = GreenLog::Logger.build(format: "json")
205
+ use GreenLog::Rack::RequestLogging, logger
206
+ ```
207
+
188
208
  ## Contributing
189
209
 
190
210
  Bug reports and pull requests are welcome on GitHub at https://github.com/greensync/green_log.
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "bundler", "~> 2.0"
29
29
  spec.add_development_dependency "pry", "~> 0.12.2"
30
30
  spec.add_development_dependency "rack"
31
- spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rake", "~> 13.0"
32
32
  spec.add_development_dependency "rspec", "~> 3.0"
33
33
  spec.add_development_dependency "rubocop", "~> 0.77"
34
34
 
@@ -5,6 +5,7 @@ require "green_log/entry"
5
5
  require "green_log/severity"
6
6
  require "green_log/severity_filter"
7
7
  require "green_log/severity_threshold_support"
8
+ require "green_log/null_writer"
8
9
  require "green_log/simple_writer"
9
10
 
10
11
  module GreenLog
@@ -84,6 +85,11 @@ module GreenLog
84
85
  GreenLog.const_get("#{format.capitalize}Writer")
85
86
  end
86
87
 
88
+ # Return a null-object Logger.
89
+ def null
90
+ new(NullWriter.new)
91
+ end
92
+
87
93
  end
88
94
 
89
95
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "green_log/entry"
4
+ require "green_log/severity"
5
+ require "json"
6
+
7
+ module GreenLog
8
+
9
+ # A road to nowhere.
10
+ class NullWriter
11
+
12
+ def initialize; end
13
+
14
+ def <<(_entry); end
15
+
16
+ def severity_threshold
17
+ Severity::FATAL
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GreenLog
4
4
 
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: green_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2020-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: values
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +134,7 @@ files:
134
134
  - lib/green_log/entry.rb
135
135
  - lib/green_log/json_writer.rb
136
136
  - lib/green_log/logger.rb
137
+ - lib/green_log/null_writer.rb
137
138
  - lib/green_log/rack/request_logging.rb
138
139
  - lib/green_log/severity.rb
139
140
  - lib/green_log/severity_filter.rb