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 +4 -4
- data/README.md +20 -0
- data/green_log.gemspec +1 -1
- data/lib/green_log/logger.rb +6 -0
- data/lib/green_log/null_writer.rb +22 -0
- data/lib/green_log/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 505b570d0cf686dae462b48c5480e527d039e8e8bdf334e400a33a88da50cd77
|
4
|
+
data.tar.gz: 75104ff8e40ae40a08913433591247f39788053da332b7f9485b386af1f1787a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/green_log.gemspec
CHANGED
@@ -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", "~>
|
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
|
|
data/lib/green_log/logger.rb
CHANGED
@@ -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
|
data/lib/green_log/version.rb
CHANGED
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.
|
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-
|
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: '
|
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: '
|
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
|