kenny 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/kenny/formatters/log_stash_formatter.rb +8 -11
- 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: 65d75df0f2a722b963a69f8556c3b424ceb233ff
|
4
|
+
data.tar.gz: 1539a9b1c5be20a58a9f81bd5dade727daf2ae06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17c5ac8693c26600b1deda013fd345dce28095e7a3c549fb36272647270685f59f60059e59870a1a8bd05840719e6cdac79c67d7f2f66d707ae782d04de80012
|
7
|
+
data.tar.gz: 4cb7efaacc2ef1ad85b7a4f3bad2ba59d99da3b1b55533bb48ad6a0725507e23ad015cfda454399bbc9b3ff2ad9f2f5670cba68c3851ed27ac1383f788c28dfb
|
data/README.md
CHANGED
@@ -152,3 +152,7 @@ Or command line:
|
|
152
152
|
Apart from subscribing to instrumentation events and logging, Kenny also provides formatters, which you can attach to a logger.
|
153
153
|
|
154
154
|
Currently, it only comes with a LogStashFormatter, but feel free to add more Formatters to make this project great.
|
155
|
+
|
156
|
+
## Release Notes
|
157
|
+
*Version 0.1.4*: LogStashFormatter can take a `type` attribute through the logger's progname. If that is nil, it falls back to the message-hash's `['type']`. If they are all nil, then `type` can still be set through FileBeat's config.
|
158
|
+
|
@@ -4,22 +4,19 @@ require 'active_support'
|
|
4
4
|
|
5
5
|
module Kenny
|
6
6
|
module Formatters
|
7
|
+
##
|
7
8
|
# Formats messages as LogStash::Event
|
9
|
+
# the 'type' field can be used for ElasticSearch
|
10
|
+
# The 'type' could be set through the Logger's progname,
|
11
|
+
# which takes the highest precedence.
|
12
|
+
# If logger.progname.nil?, it will take the 'type' within the hash.
|
13
|
+
# If the 'type' within the Hash is also nil,
|
14
|
+
# then you can set the type through FileBeat's config
|
8
15
|
class LogStashFormatter < ::Logger::Formatter
|
9
|
-
include ActiveSupport::TaggedLogging::Formatter
|
10
|
-
|
11
16
|
def call(severity, time, progname, msg)
|
12
17
|
msg = { 'message' => msg.is_a?(String) ? msg : msg.inspect } unless msg.is_a?(Hash)
|
13
|
-
|
14
18
|
msg['severity'] = severity if severity
|
15
|
-
msg['
|
16
|
-
|
17
|
-
tags = current_tags
|
18
|
-
|
19
|
-
if tags.any?
|
20
|
-
msg['type'] ||= tags.first
|
21
|
-
msg['tags'] = tags
|
22
|
-
end
|
19
|
+
msg['type'] = progname if progname
|
23
20
|
|
24
21
|
event = LogStash::Event.new(msg)
|
25
22
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kenny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Rüdiger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|