fluent-plugin-stdout-pp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/fluent-plugin-stdout-pp.gemspec +23 -0
- data/lib/fluent/plugin/out-stdout-pp.rb +57 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6886a717d98a310e6f9473afab4f35775745cb53
|
4
|
+
data.tar.gz: 15e979a86cb3c27c34325802902f8f3e7d985226
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 768197dde414398fc4112c5b10eb89bc18f19546280068c213a0600fc59369c71b1b520c22d568d1aad3931d1c1d1b43d74aaf06819082899c7784b68e985882
|
7
|
+
data.tar.gz: c6f77271e02cfc39eed4e41ca01c5d01bbc61bf9c1b9067b7208189a25c04ec147ff758f01b704cc5d3fa3b6c4342acc0ce9642c0d5baa15b8ae6736b4d54e7f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Masahiro Sano
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# fluent-plugin-stdout-pp
|
2
|
+
|
3
|
+
A fluentd plugin to pretty print json with color to stdout
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fluent-plugin-stdout-pp'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fluent-plugin-stdout-pp
|
18
|
+
|
19
|
+
## Configuration
|
20
|
+
|
21
|
+
```
|
22
|
+
<match **>
|
23
|
+
type stdout_pp
|
24
|
+
time_color blue
|
25
|
+
tag_color yellow
|
26
|
+
</match>
|
27
|
+
```
|
28
|
+
|
29
|
+
## Parameters
|
30
|
+
|
31
|
+
|parameter|description|default|
|
32
|
+
|---|---|---|
|
33
|
+
|pp| prety print json or not | true |
|
34
|
+
|time_color| color name to print time | blue |
|
35
|
+
|tag_color| color name to print tag | yellow |
|
36
|
+
|record_colored| print json with color or not | true |
|
37
|
+
|
38
|
+
Available colors:
|
39
|
+
- normal
|
40
|
+
- red
|
41
|
+
- green
|
42
|
+
- yellow
|
43
|
+
- magenta
|
44
|
+
- white
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
53
|
+
|
54
|
+
## Copyright
|
55
|
+
|
56
|
+
<table>
|
57
|
+
<tr>
|
58
|
+
<td>Author</td><td>Masahiro Sano <sabottenda@gmail.com></td>
|
59
|
+
</tr>
|
60
|
+
<tr>
|
61
|
+
<td>Copyright</td><td>Copyright (c) 2013- Masahiro Sano</td>
|
62
|
+
</tr>
|
63
|
+
<tr>
|
64
|
+
<td>License</td><td>MIT License</td>
|
65
|
+
</tr>
|
66
|
+
</table>
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-stdout-pp"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Masahiro Sano"]
|
9
|
+
spec.email = ["sabottenda@gmail.com"]
|
10
|
+
spec.description = %q{A fluentd plugin to pretty print json with color to stdout}
|
11
|
+
spec.summary = %q{A fluentd plugin to pretty print json with color to stdout}
|
12
|
+
spec.homepage = "https://github.com/sabottenda/fluent-plugin-stdout-pp"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "fluentd", "~> 0.10.0"
|
21
|
+
spec.add_dependency "coderay"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'coderay'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class StdoutPPOutput < Output
|
5
|
+
Fluent::Plugin.register_output('stdout_pp', self)
|
6
|
+
|
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
|
+
|
12
|
+
TTY_COLOR = {
|
13
|
+
normal: "\033[0;39m",
|
14
|
+
red: "\033[1;31m",
|
15
|
+
green: "\033[1;32m",
|
16
|
+
yellow: "\033[1;33m",
|
17
|
+
blue: "\033[1;34m",
|
18
|
+
magenta: "\033[1;35m",
|
19
|
+
cyan: "\033[1;36m",
|
20
|
+
white: "\033[1;37m",
|
21
|
+
}
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def configure(conf)
|
28
|
+
super
|
29
|
+
|
30
|
+
@time_color = @time_color.intern
|
31
|
+
if TTY_COLOR[@time_color].nil?
|
32
|
+
raise ConfigError, "stdout_pp: unknown color name #{@time_color} in time_color"
|
33
|
+
end
|
34
|
+
|
35
|
+
@tag_color = @tag_color.intern
|
36
|
+
if TTY_COLOR[@tag_color].nil?
|
37
|
+
raise ConfigError, "stdout_pp: unknown color name #{@tag_color} in tag_color"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def emit(tag, es, chain)
|
42
|
+
tag_colored = TTY_COLOR[@tag_color] + tag + TTY_COLOR[:normal]
|
43
|
+
es.each do |time, record|
|
44
|
+
time_colored = TTY_COLOR[@time_color] + Time.at(time).localtime.to_s + TTY_COLOR[:normal]
|
45
|
+
if @pp
|
46
|
+
json = JSON.pretty_generate(record)
|
47
|
+
else
|
48
|
+
json = Yajl.dump(record)
|
49
|
+
end
|
50
|
+
json = CodeRay.scan(json, :json).terminal if @record_colored
|
51
|
+
$log.write "#{time_colored} #{tag_colored}: #{json}\n"
|
52
|
+
end
|
53
|
+
$log.flush
|
54
|
+
chain.next
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-stdout-pp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masahiro Sano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.10.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coderay
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A fluentd plugin to pretty print json with color to stdout
|
56
|
+
email:
|
57
|
+
- sabottenda@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- fluent-plugin-stdout-pp.gemspec
|
68
|
+
- lib/fluent/plugin/out-stdout-pp.rb
|
69
|
+
homepage: https://github.com/sabottenda/fluent-plugin-stdout-pp
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.0.7
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: A fluentd plugin to pretty print json with color to stdout
|
93
|
+
test_files: []
|