fluent-plugin-stdout-pp 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/fluent-plugin-stdout-pp.gemspec +3 -2
- data/lib/fluent/plugin/out_stdout_pp.rb +13 -14
- data/test/helper.rb +5 -19
- data/test/plugin/test_out_stdout_pp.rb +22 -13
- metadata +25 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22d8905b6b920b7ad4d927cce2012bb4b0424e1d
|
4
|
+
data.tar.gz: ee54f2fa1d41a358e5888eee66390155e2777fb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4c95e90597115f1df35ce05bf047a2b0b1a326c36730f900d9bd90395d335a8425a31bfbe61e7d1cb47bc532e19a8ef2a8d95a144edd0a98724ccf5f91ff261
|
7
|
+
data.tar.gz: a088f56d35d9548e95eb413e57f30c1605759108d0777d4a89fc78f34e14dc164f2ae7479dcdf26048120f14aacdb51749f89b7eb6db7424095bccb4fa8ff234
|
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
-
# fluent-plugin-stdout-pp
|
1
|
+
# fluent-plugin-stdout-pp, a plugin for [Fluentd](https://www.fluentd.org)
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/sabottenda/fluent-plugin-stdout-pp.svg)](https://travis-ci.org/sabottenda/fluent-plugin-stdout-pp)
|
4
4
|
|
5
5
|
A fluentd plugin to pretty print json with color to stdout
|
6
6
|
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
| fluent-plugin-stdout-pp | fluentd | ruby |
|
10
|
+
|-------------------------|------------|--------|
|
11
|
+
| >= 0.2.0 | >= v0.14.0 | >= 2.1 |
|
12
|
+
| < 0.2.0 | >= v0.12.0 | >= 1.9 |
|
13
|
+
|
7
14
|
## Installation
|
8
15
|
|
9
16
|
Add this line to your application's Gemfile:
|
@@ -22,7 +29,7 @@ Or install it yourself as:
|
|
22
29
|
|
23
30
|
```
|
24
31
|
<match **>
|
25
|
-
type stdout_pp
|
32
|
+
@type stdout_pp
|
26
33
|
time_color blue
|
27
34
|
tag_color yellow
|
28
35
|
</match>
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-stdout-pp"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.2.0"
|
8
8
|
spec.authors = ["Masahiro Sano"]
|
9
9
|
spec.email = ["sabottenda@gmail.com"]
|
10
10
|
spec.description = %q{A fluentd plugin to pretty print json with color to stdout}
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "fluentd"
|
20
|
+
spec.add_dependency "fluentd", ">= 0.14.12", "< 2"
|
21
21
|
spec.add_dependency "coderay"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "test-unit", "> 3"
|
23
24
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'coderay'
|
2
2
|
|
3
|
-
module Fluent
|
4
|
-
class StdoutPPOutput < Output
|
3
|
+
module Fluent::Plugin
|
4
|
+
class StdoutPPOutput < Fluent::Plugin::Output
|
5
5
|
Fluent::Plugin.register_output('stdout_pp', self)
|
6
6
|
|
7
|
-
config_param :pp, :bool, :
|
8
|
-
config_param :time_color, :string, :
|
9
|
-
config_param :tag_color, :string, :
|
10
|
-
config_param :record_colored, :bool, :
|
7
|
+
config_param :pp, :bool, default: true
|
8
|
+
config_param :time_color, :string, default: 'blue'
|
9
|
+
config_param :tag_color, :string, default: 'yellow'
|
10
|
+
config_param :record_colored, :bool, default: true
|
11
11
|
|
12
12
|
TTY_COLOR = {
|
13
13
|
normal: "\033[0;39m",
|
@@ -20,10 +20,6 @@ module Fluent
|
|
20
20
|
white: "\033[1;37m",
|
21
21
|
}
|
22
22
|
|
23
|
-
def initialize
|
24
|
-
super
|
25
|
-
end
|
26
|
-
|
27
23
|
def configure(conf)
|
28
24
|
super
|
29
25
|
|
@@ -38,7 +34,7 @@ module Fluent
|
|
38
34
|
end
|
39
35
|
end
|
40
36
|
|
41
|
-
def
|
37
|
+
def process(tag, es)
|
42
38
|
tag_colored = TTY_COLOR[@tag_color] + tag + TTY_COLOR[:normal]
|
43
39
|
es.each do |time, record|
|
44
40
|
time_colored = TTY_COLOR[@time_color] + Time.at(time).localtime.to_s + TTY_COLOR[:normal]
|
@@ -48,10 +44,13 @@ module Fluent
|
|
48
44
|
json = Yajl.dump(record)
|
49
45
|
end
|
50
46
|
json = CodeRay.scan(json, :json).terminal if @record_colored
|
51
|
-
|
47
|
+
log.write "#{time_colored} #{tag_colored}: #{json}\n"
|
52
48
|
end
|
53
|
-
|
54
|
-
|
49
|
+
log.flush
|
50
|
+
end
|
51
|
+
|
52
|
+
def multi_workers_ready?
|
53
|
+
true
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
data/test/helper.rb
CHANGED
@@ -1,23 +1,9 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift(File.join(
|
4
|
-
$LOAD_PATH.unshift(
|
3
|
+
$LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
|
4
|
+
$LOAD_PATH.unshift(__dir__)
|
5
5
|
require 'fluent/test'
|
6
|
+
require 'fluent/test/driver/output'
|
7
|
+
require 'fluent/test/helpers'
|
6
8
|
|
7
|
-
|
8
|
-
old = $log
|
9
|
-
$log = StringIO.new
|
10
|
-
yield
|
11
|
-
return $log.string
|
12
|
-
ensure
|
13
|
-
$log = old
|
14
|
-
end
|
15
|
-
|
16
|
-
# def capture
|
17
|
-
# old = $stdout
|
18
|
-
# $stdout = StringIO.new('','w')
|
19
|
-
# yield
|
20
|
-
# $stdout.string
|
21
|
-
# ensure
|
22
|
-
# $stdout = old
|
23
|
-
# end
|
9
|
+
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
@@ -10,7 +10,7 @@ class StdoutOutputPPTest < Test::Unit::TestCase
|
|
10
10
|
]
|
11
11
|
|
12
12
|
def create_driver(conf = CONFIG)
|
13
|
-
Fluent::Test::
|
13
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::StdoutPPOutput).configure(conf)
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_configure
|
@@ -19,28 +19,37 @@ class StdoutOutputPPTest < Test::Unit::TestCase
|
|
19
19
|
assert_equal Symbol, d.instance.tag_color.class
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def test_process
|
23
23
|
d = create_driver
|
24
|
-
time =
|
25
|
-
|
26
|
-
|
24
|
+
time = event_time
|
25
|
+
localtime = time2str(time, localtime: true, format: '%Y-%m-%d %H:%M:%S %z')
|
26
|
+
d.run(default_tag: 'test') do
|
27
|
+
d.feed(time, {'test' => 'test'})
|
28
|
+
end
|
29
|
+
assert_equal "\e[1;34m#{localtime}\e[0;39m \e[1;33mtest\e[0;39m: {\n \e[35m\e[1;35m\"\e[0m\e[35mtest\e[1;35m\"\e[0m\e[35m\e[0m: \e[31m\e[1;31m\"\e[0m\e[31mtest\e[1;31m\"\e[0m\e[31m\e[0m\n}\n", d.logs.first
|
27
30
|
end
|
28
31
|
|
29
|
-
def
|
32
|
+
def test_process_no_color
|
30
33
|
d = create_driver(CONFIG + "record_colored false\n")
|
31
|
-
time =
|
34
|
+
time = event_time
|
35
|
+
localtime = time2str(time, localtime: true, format: '%Y-%m-%d %H:%M:%S %z')
|
32
36
|
record = {'test' => 'test'}
|
33
|
-
|
34
|
-
|
37
|
+
d.run(default_tag: 'test') do
|
38
|
+
d.feed(time, record)
|
39
|
+
end
|
40
|
+
assert_equal "\e[1;34m#{localtime}\e[0;39m \e[1;33mtest\e[0;39m: #{JSON.pretty_generate(record)}\n", d.logs.first
|
35
41
|
end
|
36
42
|
|
37
|
-
def
|
43
|
+
def test_process_without_pp
|
38
44
|
d = create_driver(CONFIG + "pp false\n")
|
39
|
-
time =
|
45
|
+
time = event_time
|
46
|
+
localtime = time2str(time, localtime: true, format: '%Y-%m-%d %H:%M:%S %z')
|
40
47
|
record = {'test' => 'test'}
|
41
|
-
|
48
|
+
d.run(default_tag: 'test') do
|
49
|
+
d.feed(time, record)
|
50
|
+
end
|
42
51
|
|
43
|
-
assert_equal "\e[1;34m#{
|
52
|
+
assert_equal "\e[1;34m#{localtime}\e[0;39m \e[1;33mtest\e[0;39m: {\e[35m\e[1;35m\"\e[0m\e[35mtest\e[1;35m\"\e[0m\e[35m\e[0m:\e[31m\e[1;31m\"\e[0m\e[31mtest\e[1;31m\"\e[0m\e[31m\e[0m}\n", d.logs.first
|
44
53
|
end
|
45
54
|
end
|
46
55
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-stdout-pp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Sano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.14.12
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 0.14.12
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: coderay
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +58,20 @@ dependencies:
|
|
52
58
|
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: test-unit
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3'
|
55
75
|
description: A fluentd plugin to pretty print json with color to stdout
|
56
76
|
email:
|
57
77
|
- sabottenda@gmail.com
|
@@ -88,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
108
|
version: '0'
|
89
109
|
requirements: []
|
90
110
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.6.13
|
92
112
|
signing_key:
|
93
113
|
specification_version: 4
|
94
114
|
summary: A fluentd plugin to pretty print json with color to stdout
|