lumberjack 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +10 -0
- data/VERSION +1 -1
- data/lib/lumberjack/logger.rb +1 -0
- data/lib/lumberjack/tags.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6869d51bf38cc7ee1aad46005d947c5313bf58064da86cbd44ab5ca69dd04a71
|
4
|
+
data.tar.gz: 2817b2ace992f96770a16f1f5d6133a06f1e7277dfe236deb31d8fcad9934d39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6419348e19de6901892b35118ebc4405a773706b817d5c3c443f733973a977ad3be171b1f736b81334d9173cae5271799e267917284d3a28459349bc0cfc76f7
|
7
|
+
data.tar.gz: 5dca009d8cc55ea4044e9eba50df1ebba04351d019c3322b733ae01fc0d250f29d3a9f625c67da3549a0a7ebf8487a465f1ff4cca1ccfccf662f1cbccc4629cd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -63,6 +63,16 @@ end
|
|
63
63
|
logger.info("there") # Will not include the `thread_id` tag
|
64
64
|
```
|
65
65
|
|
66
|
+
You can also set tags to `Proc` objects that will be evaluated when creating a log entry.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
logger.tag(thread_id: lambda { Thread.current.object_id })
|
70
|
+
Thread.new do
|
71
|
+
logger.info("inside thread") # Will include the `thread_id` tag with id of the spawned thread
|
72
|
+
end
|
73
|
+
logger.info("outside thread") # Will include the `thread_id` tag with id of the main thread
|
74
|
+
```
|
75
|
+
|
66
76
|
Finally, you can specify a logging context with tags that apply within a block to all loggers.
|
67
77
|
|
68
78
|
```ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/lib/lumberjack/logger.rb
CHANGED
data/lib/lumberjack/tags.rb
CHANGED
@@ -19,6 +19,24 @@ module Lumberjack
|
|
19
19
|
copy
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
# Ensure keys are strings and expand any values in a hash that are Proc's by calling them and replacing
|
24
|
+
# the value with the result. This allows setting global tags with runtime values.
|
25
|
+
def expand_runtime_values(hash)
|
26
|
+
return nil if hash.nil?
|
27
|
+
if hash.all? { |key, value| key.is_a?(String) && !value.is_a?(Proc) }
|
28
|
+
return hash
|
29
|
+
end
|
30
|
+
|
31
|
+
copy = {}
|
32
|
+
hash.each do |key, value|
|
33
|
+
if value.is_a?(Proc) && (value.arity == 0 || value.arity == -1)
|
34
|
+
value = value.call
|
35
|
+
end
|
36
|
+
copy[key.to_s] = value
|
37
|
+
end
|
38
|
+
copy
|
39
|
+
end
|
22
40
|
end
|
23
41
|
end
|
24
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lumberjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|