green_log 0.2.0 → 1.0.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 +3 -2
- data/green_log.gemspec +4 -3
- data/lib/green_log/core_refinements.rb +8 -0
- data/lib/green_log/entry.rb +23 -4
- data/lib/green_log/rack/request_logging.rb +9 -5
- data/lib/green_log/version.rb +1 -1
- metadata +10 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5b5433755b4109fd922e8b52ddb5548f197a138828440db5a34d3e36cbfef7a
|
4
|
+
data.tar.gz: 7662ef6e5b9ffa36b325ef0a35d024291063a5862824e98c026e0792a5d50947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba12d366ae1cad087af69a2f237657f5f25671dce6f9c0ad91394afa63ec0b6f537906f022dabc8e5bf00c973504f4353c9500e4d80481eec530eb58c930f905
|
7
|
+
data.tar.gz: 640bd883b9b8acb70d338e67d7c891f816a9763e73fe19e249c7de52c642fb56067bc31c9769a4a154f35bf64752cee7e5150893c23a5c2520f17ed564192beb
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# GreenLog
|
2
2
|
|
3
|
-
![](https://
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/green_log.svg)](http://badge.fury.io/rb/green_log)
|
4
|
+
[![Build Status](https://github.com/mdub/green_log/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mdub/green_log/actions/workflows/ci.yml)
|
4
5
|
|
5
6
|
GreenLog is a logging library for Ruby applications. It:
|
6
7
|
|
@@ -207,7 +208,7 @@ use GreenLog::Rack::RequestLogging, logger
|
|
207
208
|
|
208
209
|
## Contributing
|
209
210
|
|
210
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
211
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mdub/green_log.
|
211
212
|
|
212
213
|
## License
|
213
214
|
|
data/green_log.gemspec
CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = "green_log"
|
9
9
|
spec.version = GreenLog::VERSION
|
10
10
|
spec.authors = ["Mike Williams"]
|
11
|
-
spec.email = ["
|
11
|
+
spec.email = ["mdub@dogbiscuit.org"]
|
12
12
|
|
13
13
|
spec.summary = "Structured logging for cloud-native systems."
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/mdub/green_log"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
@@ -24,7 +24,8 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.
|
27
|
+
spec.required_ruby_version = ">= 2.7.0"
|
28
|
+
|
28
29
|
spec.add_development_dependency "bundler", "~> 2.0"
|
29
30
|
spec.add_development_dependency "pry", "~> 0.12.2"
|
30
31
|
spec.add_development_dependency "rack"
|
data/lib/green_log/entry.rb
CHANGED
@@ -2,15 +2,28 @@
|
|
2
2
|
|
3
3
|
require "green_log/core_refinements"
|
4
4
|
require "green_log/severity"
|
5
|
-
require "values"
|
6
5
|
|
7
6
|
module GreenLog
|
8
7
|
|
9
8
|
# Represents a structured log entry.
|
10
|
-
class Entry
|
9
|
+
class Entry
|
11
10
|
|
12
11
|
using CoreRefinements
|
13
12
|
|
13
|
+
def initialize(severity:, message:, context:, data:, exception:)
|
14
|
+
@severity = severity
|
15
|
+
@message = message
|
16
|
+
@context = context
|
17
|
+
@data = data
|
18
|
+
@exception = exception
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :severity
|
22
|
+
attr_reader :message
|
23
|
+
attr_reader :context
|
24
|
+
attr_reader :data
|
25
|
+
attr_reader :exception
|
26
|
+
|
14
27
|
class << self
|
15
28
|
|
16
29
|
def with(**args)
|
@@ -21,7 +34,7 @@ module GreenLog
|
|
21
34
|
args[:context] = args.fetch(:context, {}).to_loggable_value
|
22
35
|
args[:data] = args.fetch(:data, {}).to_loggable_value
|
23
36
|
args[:exception] ||= nil
|
24
|
-
|
37
|
+
new(**args)
|
25
38
|
end
|
26
39
|
|
27
40
|
def build(severity, *args, &block)
|
@@ -31,7 +44,13 @@ module GreenLog
|
|
31
44
|
end
|
32
45
|
|
33
46
|
def in_context(extra_context)
|
34
|
-
|
47
|
+
Entry.new(
|
48
|
+
severity: severity,
|
49
|
+
message: message,
|
50
|
+
context: extra_context.integrate(context).to_loggable_value,
|
51
|
+
data: data,
|
52
|
+
exception: exception,
|
53
|
+
)
|
35
54
|
end
|
36
55
|
|
37
56
|
# A builder for entries.
|
@@ -64,11 +64,15 @@ module GreenLog
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def request_body(request)
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
return "" if request.body.size.zero?
|
68
|
+
|
69
|
+
begin
|
70
|
+
original_position = request.body.pos
|
71
|
+
request.body.rewind
|
72
|
+
request.body.read
|
73
|
+
ensure
|
74
|
+
request.body.seek(original_position)
|
75
|
+
end
|
72
76
|
end
|
73
77
|
|
74
78
|
def response_details(response)
|
data/lib/green_log/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: green_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: values
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.8'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.8'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,9 +94,9 @@ dependencies:
|
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0.77'
|
111
|
-
description:
|
97
|
+
description:
|
112
98
|
email:
|
113
|
-
-
|
99
|
+
- mdub@dogbiscuit.org
|
114
100
|
executables: []
|
115
101
|
extensions: []
|
116
102
|
extra_rdoc_files: []
|
@@ -141,11 +127,11 @@ files:
|
|
141
127
|
- lib/green_log/severity_threshold_support.rb
|
142
128
|
- lib/green_log/simple_writer.rb
|
143
129
|
- lib/green_log/version.rb
|
144
|
-
homepage: https://github.com/
|
130
|
+
homepage: https://github.com/mdub/green_log
|
145
131
|
licenses:
|
146
132
|
- MIT
|
147
133
|
metadata: {}
|
148
|
-
post_install_message:
|
134
|
+
post_install_message:
|
149
135
|
rdoc_options: []
|
150
136
|
require_paths:
|
151
137
|
- lib
|
@@ -153,15 +139,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
139
|
requirements:
|
154
140
|
- - ">="
|
155
141
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
142
|
+
version: 2.7.0
|
157
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
144
|
requirements:
|
159
145
|
- - ">="
|
160
146
|
- !ruby/object:Gem::Version
|
161
147
|
version: '0'
|
162
148
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
164
|
-
signing_key:
|
149
|
+
rubygems_version: 3.1.2
|
150
|
+
signing_key:
|
165
151
|
specification_version: 4
|
166
152
|
summary: Structured logging for cloud-native systems.
|
167
153
|
test_files: []
|