uu 0.2.0 → 0.2.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/Gemfile.lock +1 -1
- data/lib/uu/log.rb +1 -1
- data/lib/uu/log_context.rb +4 -0
- data/lib/uu/loggable.rb +2 -0
- data/lib/uu/logger_fluent.rb +19 -24
- data/lib/uu/version.rb +1 -1
- 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: 8b7321eb0a2d0928bc20c2ee316c730243f3cb10b1fe4eda29d18d4d6507a81a
|
4
|
+
data.tar.gz: cedd60c4e5b0606e31e7f2aec8fe6db9dd426f00cf2c8d8e768d52a6268e0d58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99a5ff6fc748b2f6632f76f987f53130127c427a81ad1ff4d92fbede3fb989703e6e19d15cfcdb3391455cf5a27b8d8be9fd4c7c4b1fe2a1778200175e310ce8
|
7
|
+
data.tar.gz: 2a48f11663da10487d6be1cc117dbb09add2325a5056c169684dc4d0fdaf6011ab1eb7cb2507dcaf07d00d822224e88805da8dc612f2d6fa3a4941ae95fb4796
|
data/Gemfile.lock
CHANGED
data/lib/uu/log.rb
CHANGED
data/lib/uu/log_context.rb
CHANGED
data/lib/uu/loggable.rb
CHANGED
data/lib/uu/logger_fluent.rb
CHANGED
@@ -5,19 +5,24 @@ require 'fluent-logger'
|
|
5
5
|
module UU
|
6
6
|
class LoggerFluent
|
7
7
|
class Formatter
|
8
|
-
|
8
|
+
DEFAULT_TAG = 'fluentd'
|
9
|
+
@tag = ENV['FLUENTD_TAG'] || DEFAULT_TAG
|
10
|
+
class << self
|
11
|
+
attr_accessor :tag
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(context)
|
9
15
|
@context = context
|
10
|
-
@tag = tag
|
11
16
|
end
|
12
17
|
|
13
18
|
attr_reader :context
|
14
19
|
|
15
20
|
def call(severity, msg)
|
16
|
-
[
|
21
|
+
[self.class.tag, {
|
17
22
|
log_level: severity,
|
18
23
|
**metadata,
|
19
|
-
message: msg,
|
20
24
|
**@context.context,
|
25
|
+
**(msg.is_a?(Hash) ? msg : { message: msg }),
|
21
26
|
}]
|
22
27
|
end
|
23
28
|
|
@@ -51,29 +56,19 @@ module UU
|
|
51
56
|
|
52
57
|
NIL = Nil.new
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
nil,
|
58
|
-
nanosecond_precision: true,
|
59
|
-
**key,
|
60
|
-
)
|
59
|
+
def initialize(cxt, host: ENV['FLUENTD_HOST'], port: ENV['FLUENTD_PORT'])
|
60
|
+
@logger = create_logger(host, port)
|
61
|
+
@formatter = Formatter.new(cxt)
|
61
62
|
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
end
|
64
|
+
def create_logger(host, port)
|
65
|
+
return NIL unless host
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
]
|
73
|
-
else
|
74
|
-
NIL
|
75
|
-
end
|
76
|
-
@formatter = Formatter.new(cxt, 'tag')
|
67
|
+
Fluent::Logger::FluentLogger.new(
|
68
|
+
nil,
|
69
|
+
nanosecond_precision: true,
|
70
|
+
host: host, **(port ? { port: port.to_i } : {})
|
71
|
+
)
|
77
72
|
end
|
78
73
|
|
79
74
|
attr_reader :logger
|
data/lib/uu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minwoo Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|