klogger-logger 1.4.0 → 1.5.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 +6 -1
- data/VERSION +1 -1
- data/lib/klogger/logger.rb +9 -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: 545977913e2a22754ceaa46726ed6c1ccaa28c4af5ff3bda20ddf76fbf0783ad
|
4
|
+
data.tar.gz: db4cd99e286083d70e768f659cb1446ab4d289a6ed6bbb36ae4f51000771e9ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30e4cb6330c169eea17379c012bca5e0b829fe06a4f2bd4597e5d7cde189c981aa514ce4e891ee7e32dcafc3391d8856db440cf759b8b8769abf51ec890f7d40
|
7
|
+
data.tar.gz: 39ceffeb22baa21c39f3ef2461a3e469535340e77bbb6795d59fc74078db17b813576c2f9a1df42f476e87cd16d6af295e88ecf3e83d6d047cb60accc9a4bc5f
|
data/README.md
CHANGED
@@ -78,7 +78,7 @@ logger.info { "Hello world!" }
|
|
78
78
|
logger.info('Result of 1 + 1') { 1 + 1 } # Logs with a message of "Result: 2"
|
79
79
|
```
|
80
80
|
|
81
|
-
###
|
81
|
+
### Logging exceptions
|
82
82
|
|
83
83
|
Exceptions happen and when they do, you want to know about them. Klogger provides a helper method to log exceptions. These will automatically be logged with the `error` severity.
|
84
84
|
|
@@ -197,4 +197,9 @@ end
|
|
197
197
|
# Create a logger and add the destination
|
198
198
|
logger = Klogger.new(name)
|
199
199
|
logger.add_destination(GraylogDestination.new('graylog.example.com', 12201))
|
200
|
+
|
201
|
+
# If you only want to send certain data to another block, you can do so
|
202
|
+
logger.with_destination(other_destination) do
|
203
|
+
# ...
|
204
|
+
end
|
200
205
|
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.0
|
data/lib/klogger/logger.rb
CHANGED
@@ -36,6 +36,7 @@ module Klogger
|
|
36
36
|
@destinations = []
|
37
37
|
@group_set = GroupSet.new
|
38
38
|
@silenced = Concurrent::ThreadLocalVar.new { false }
|
39
|
+
@block_destinations = Concurrent::ThreadLocalVar.new { [] }
|
39
40
|
@include_group_ids = include_group_ids
|
40
41
|
super(destination)
|
41
42
|
self.formatter = FORMATTERS[formatter].new(highlight: highlight)
|
@@ -98,6 +99,13 @@ module Klogger
|
|
98
99
|
@destinations.delete(destination)
|
99
100
|
end
|
100
101
|
|
102
|
+
def with_destination(destination)
|
103
|
+
@block_destinations.value << destination
|
104
|
+
yield
|
105
|
+
ensure
|
106
|
+
@block_destinations.value.delete(destination)
|
107
|
+
end
|
108
|
+
|
101
109
|
def create_tagged_logger(**tags)
|
102
110
|
TaggedLogger.new(self, **tags)
|
103
111
|
end
|
@@ -142,7 +150,7 @@ module Klogger
|
|
142
150
|
end
|
143
151
|
|
144
152
|
def call_destinations(payload, group_ids)
|
145
|
-
@destinations.each do |destination|
|
153
|
+
(@destinations + @block_destinations.value).each do |destination|
|
146
154
|
destination.call(self, payload.dup, group_ids)
|
147
155
|
rescue StandardError => e
|
148
156
|
# If something goes wrong in here, we don't want to break the application
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klogger-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
rubygems_version: 3.3.
|
108
|
+
rubygems_version: 3.3.27
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: A simple Ruby logger
|