yog 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/yog.rb +6 -3
- data/yog.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9a3d2332f241fe9669c87eb122afa62b618085a97764a095c28eca89652af8a
|
4
|
+
data.tar.gz: dcfa5e22597ab26cc93981e67ca358dba1dda6a5bc8a8980af9306a93e426979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e2b87bfd01745ece125d06e30b1892b10dc8d10da48198ce2edd1c7703eba25d123eac3d3589031ee019eb487b93b97ec3665490c4a7c28726942b37918a32
|
7
|
+
data.tar.gz: 3df18c59fe3eaac77a87c89c92ccbf202b5a4ac02d4a85ee5294ad188df8abce2b4e74e17011070674bf1e5f8098fd406c0093164a37e2e45838874a1d8cfbc8
|
data/Gemfile.lock
CHANGED
data/lib/yog.rb
CHANGED
@@ -5,6 +5,9 @@ require "yog/logfmt"
|
|
5
5
|
# Writes structured log lines.
|
6
6
|
class Yog
|
7
7
|
|
8
|
+
# This context is included in every log line.
|
9
|
+
GLOBAL = {}
|
10
|
+
|
8
11
|
# Get ready to do some yogging.
|
9
12
|
def initialize(generator: Logfmt, output: $stdout, context: {})
|
10
13
|
@context = context
|
@@ -37,7 +40,7 @@ class Yog
|
|
37
40
|
prefix[:duration] = (Time.now - start) * 1000
|
38
41
|
end
|
39
42
|
|
40
|
-
combined = prefix.merge(@context).merge(fields)
|
43
|
+
combined = prefix.merge(GLOBAL).merge(@context).merge(fields)
|
41
44
|
@output.puts(@generator.generate(combined))
|
42
45
|
|
43
46
|
result
|
@@ -61,14 +64,14 @@ class Yog
|
|
61
64
|
output: @output
|
62
65
|
end
|
63
66
|
|
64
|
-
###
|
67
|
+
### Static helpers
|
65
68
|
|
66
69
|
# The log for Yog(), Yog.set(), and Yog.with().
|
67
70
|
def self.default
|
68
71
|
logs.first
|
69
72
|
end
|
70
73
|
|
71
|
-
# A stack of receivers
|
74
|
+
# A stack of thread-local receivers, current log first.
|
72
75
|
def self.logs
|
73
76
|
Thread.current[:logs] ||= [new]
|
74
77
|
end
|
data/yog.gemspec
CHANGED