name_tagged_cee_syslogger 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/name_tagged_cee_syslogger/logger.rb +36 -6
- data/lib/name_tagged_cee_syslogger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7ab6cd6d124341745a11abee92226e346f3ec3d
|
4
|
+
data.tar.gz: 7c6dacabc576404f4548d24268385b5c54463dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4447185ef037b01ceb52240371a2f144b71bb45b5a545f4c99302a2aa672596b1e228affafb7f4274165aa01710f9c2d9c05cb4df85381584c74e564ad4c8c2
|
7
|
+
data.tar.gz: c9d74ebe9964c4a732c606acba7921d2da1aeb361ce2ec6c2d2eb0ed53f1b23e25e0b6f32cff67752ea5c621f7f5a0270bfe143860dd75aa1c60a93a3e9f9ca3
|
@@ -22,17 +22,47 @@ module NameTaggedCeeSyslogger
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def merge_tags(message)
|
25
|
-
|
25
|
+
if message.is_a?(Hash)
|
26
|
+
message = message.each_with_object({}) do |(k,v), acc|
|
27
|
+
acc[k.to_sym] = v
|
28
|
+
end
|
29
|
+
else
|
26
30
|
message = { msg: message }
|
27
31
|
end
|
28
32
|
|
29
|
-
current_tags.
|
30
|
-
if tag.is_a?(Hash)
|
31
|
-
message.merge!(tag)
|
32
|
-
end
|
33
|
-
end
|
33
|
+
message = current_tags.merge(message)
|
34
34
|
|
35
35
|
message
|
36
36
|
end
|
37
|
+
|
38
|
+
def tagged(tags)
|
39
|
+
old_tags = current_tags.dup
|
40
|
+
|
41
|
+
begin
|
42
|
+
add_tags(tags)
|
43
|
+
yield self
|
44
|
+
ensure
|
45
|
+
set_tags(old_tags)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def add_tags(tags)
|
52
|
+
return unless tags.is_a?(Hash)
|
53
|
+
|
54
|
+
tags.each do |(k,v)|
|
55
|
+
current_tags[k.to_sym] = v
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_tags(tags)
|
60
|
+
clear_tags!
|
61
|
+
add_tags(tags)
|
62
|
+
end
|
63
|
+
|
64
|
+
def current_tags
|
65
|
+
Thread.current[:name_tagged_logger_tags] ||= {}
|
66
|
+
end
|
37
67
|
end
|
38
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: name_tagged_cee_syslogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Donald Plummer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: syslogger
|