log_sinks 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/lib/log_sinks/log_event.rb +7 -21
- data/lib/log_sinks/logger.rb +1 -1
- data/lib/log_sinks/mdc.rb +4 -0
- data/lib/log_sinks/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b2cfa948d6048c9c99682ba32a3c89bd59d7d33ccbda18353d4581e48a44c0e
|
4
|
+
data.tar.gz: c256d194a28d23478e87a5002208143f33d7f5324f579a4ac6c15e9b764076cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67abc22d62f8c8e381376bf1eca20c3e276b60284678e11ff39853bd51ebb43001512e55dd57013648a97bfdefa4f863c007484aab2127f134c6053e83fbed79
|
7
|
+
data.tar.gz: 8f2a78e041a9dd074a65269ead3c9b1481fa07ca357ecb8d6d030536089398bf714d993aad8dda6ff91bd9a160cd602363ea3f50f01bac537866335ad152b6fd
|
data/lib/log_sinks/log_event.rb
CHANGED
@@ -3,28 +3,14 @@
|
|
3
3
|
module LogSinks
|
4
4
|
# Represents a log event.
|
5
5
|
class LogEvent
|
6
|
-
|
7
|
-
@data = meta || {}
|
8
|
-
@data[:timestamp] = timestamp
|
9
|
-
@data[:level] = level
|
10
|
-
@data[:logger_name] = logger_name
|
11
|
-
@data[:message] = msg
|
12
|
-
end
|
6
|
+
attr_reader :timestamp, :level, :logger_name, :message, :data
|
13
7
|
|
14
|
-
def timestamp
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def logger_name
|
23
|
-
self[:logger_name]
|
24
|
-
end
|
25
|
-
|
26
|
-
def message
|
27
|
-
self[:message]
|
8
|
+
def initialize(timestamp, level, logger_name, msg, meta: nil)
|
9
|
+
@data = (meta || {}).freeze
|
10
|
+
@timestamp = timestamp
|
11
|
+
@level = level
|
12
|
+
@logger_name = logger_name
|
13
|
+
@message = msg
|
28
14
|
end
|
29
15
|
|
30
16
|
def [](key)
|
data/lib/log_sinks/logger.rb
CHANGED
@@ -57,7 +57,7 @@ module LogSinks
|
|
57
57
|
msg = yield if msg.nil? && block_given?
|
58
58
|
meta ||= {}
|
59
59
|
meta[:error] = error unless error.nil?
|
60
|
-
meta.merge!(MDC.items)
|
60
|
+
meta.merge!(MDC.items) if MDC.any?
|
61
61
|
event = ::LogSinks::LogEvent.new(Time.now, level, @name, msg, meta: meta)
|
62
62
|
dispatch_event event
|
63
63
|
end
|
data/lib/log_sinks/mdc.rb
CHANGED
data/lib/log_sinks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_sinks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Maraev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.1.0
|
48
|
-
type: :
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|