fluent-plugin-formatter_sprintf 0.0.4 → 0.1.0
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/.travis.yml +0 -1
- data/README.md +18 -9
- data/fluent-plugin-formatter_sprintf.gemspec +1 -1
- data/lib/fluent/plugin/formatter_sprintf.rb +4 -5
- data/test/test_formatter_sprintf.rb +8 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a1ce6bc172f625cbd6b94723ea9f7e54f4fbe07
|
4
|
+
data.tar.gz: fa4978e679300e261940494a8844c85fba30d836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ba2e31925a7e61344f45c1016b2f8402e3e0ca2149b0c14b042c575fb1194db8173f716ef4f6a5cae1ea135f7f6b8c14d002a826c16f52489d62337105c1823
|
7
|
+
data.tar.gz: c049c276211a87372f7b0583762404dbd363c5e717f2aa47b216558c1d336a75bd65be9bb24e8bbd84e3110b2bfb51fc99ce68bec425fd5469b92d8cbd1932bc
|
data/README.md
CHANGED
@@ -22,8 +22,10 @@ gem install fluent-plugin-formatter_sprintf
|
|
22
22
|
<match test.file>
|
23
23
|
type file
|
24
24
|
path /tmp/test.log
|
25
|
-
format
|
26
|
-
|
25
|
+
<format>
|
26
|
+
@type sprintf
|
27
|
+
sprintf_format "${tag} ${time} ${url} ${ip_address}\n"
|
28
|
+
</format>
|
27
29
|
time_format "%Y-%m-%d %H:%M:%S"
|
28
30
|
</match>
|
29
31
|
```
|
@@ -47,18 +49,21 @@ gem install fluent-plugin-formatter_sprintf
|
|
47
49
|
time_format %Y-%m-%d %H:%M:%S,%3N
|
48
50
|
store_as text
|
49
51
|
|
50
|
-
format
|
51
|
-
|
52
|
-
|
52
|
+
<format>
|
53
|
+
@type sprintf
|
54
|
+
sprintf_format "${tag} ${time} ${url} ${ip_address}\n"
|
55
|
+
</format>
|
53
56
|
</match>
|
54
57
|
```
|
55
58
|
|
56
59
|
### blank string(include [nil, empty?, blank?])
|
57
60
|
|
58
61
|
```apache
|
59
|
-
format
|
60
|
-
|
61
|
-
|
62
|
+
<format>
|
63
|
+
@type sprintf
|
64
|
+
sprintf_format "${tag} ${time} ${url} ${ip_address}\n"
|
65
|
+
sprintf_blank_string -
|
66
|
+
</format>
|
62
67
|
```
|
63
68
|
|
64
69
|
##### input
|
@@ -73,8 +78,12 @@ analysis.pageview 2016-01-01 00:00:00 - -
|
|
73
78
|
|
74
79
|
### bad syntax(at error)
|
75
80
|
|
81
|
+
```apache
|
82
|
+
<format>
|
83
|
+
@type sprintf
|
76
84
|
sprintf_format "%s ${tag} ${time} ${url} ${ip_address}\n"
|
77
|
-
|
85
|
+
</format>
|
86
|
+
```
|
78
87
|
|
79
88
|
## ChangeLog
|
80
89
|
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-formatter_sprintf"
|
6
|
-
s.version = "0.0
|
6
|
+
s.version = "0.1.0"
|
7
7
|
s.authors = ["Hiroshi Toyama"]
|
8
8
|
s.email = ["toyama0919@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/toyama0919/fluent-plugin-formatter_sprintf"
|
@@ -1,10 +1,9 @@
|
|
1
|
+
require 'fluent/plugin/formatter'
|
2
|
+
|
1
3
|
module Fluent
|
2
|
-
module
|
4
|
+
module Plugin
|
3
5
|
class SprintfFormatter < Formatter
|
4
|
-
Plugin.register_formatter('sprintf', self)
|
5
|
-
|
6
|
-
include Configurable
|
7
|
-
include HandleTagAndTimeMixin
|
6
|
+
Fluent::Plugin.register_formatter('sprintf', self)
|
8
7
|
|
9
8
|
config_param :sprintf_format, :string
|
10
9
|
config_param :sprintf_blank_string, :string, :default => nil
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'helper'
|
2
|
+
require 'fluent/test/driver/formatter'
|
2
3
|
require 'fluent/formatter'
|
3
4
|
require 'fluent/plugin/formatter_sprintf'
|
4
5
|
|
@@ -9,7 +10,7 @@ class SprintfFormatterTest < ::Test::Unit::TestCase
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def create_driver(conf={})
|
12
|
-
Fluent::Test::
|
13
|
+
Fluent::Test::Driver::Formatter.new(Fluent::Plugin::SprintfFormatter).configure(conf)
|
13
14
|
end
|
14
15
|
|
15
16
|
def configure(conf)
|
@@ -21,7 +22,7 @@ class SprintfFormatterTest < ::Test::Unit::TestCase
|
|
21
22
|
tag = 'file.test'
|
22
23
|
record = {"url" => "/", "ip_address" => "127.0.0.1"}
|
23
24
|
|
24
|
-
formatted = @formatter.format(tag, @time, record)
|
25
|
+
formatted = @formatter.instance.format(tag, @time, record)
|
25
26
|
assert_equal("file.test / 127.0.0.1\n", formatted)
|
26
27
|
end
|
27
28
|
|
@@ -30,7 +31,7 @@ class SprintfFormatterTest < ::Test::Unit::TestCase
|
|
30
31
|
tag = 'file.test'
|
31
32
|
record = {"url" => "/", "ip_address" => "127.0.0.1"}
|
32
33
|
|
33
|
-
formatted = @formatter.format(tag, @time, record)
|
34
|
+
formatted = @formatter.instance.format(tag, @time, record)
|
34
35
|
assert_equal("file.test\t/\t127.0.0.1\n", formatted)
|
35
36
|
end
|
36
37
|
|
@@ -53,7 +54,7 @@ class SprintfFormatterTest < ::Test::Unit::TestCase
|
|
53
54
|
tag = 'file.test'
|
54
55
|
record = {"id" => 1, "ip_address" => "127.0.0.1"}
|
55
56
|
|
56
|
-
formatted = @formatter.format(tag, @time, record)
|
57
|
+
formatted = @formatter.instance.format(tag, @time, record)
|
57
58
|
assert_equal("file.test\t1\t127.0.0.1\n", formatted)
|
58
59
|
end
|
59
60
|
|
@@ -67,7 +68,7 @@ class SprintfFormatterTest < ::Test::Unit::TestCase
|
|
67
68
|
tag = 'file.test'
|
68
69
|
record = {"id" => nil, "ip_address" => "", "space" => " "}
|
69
70
|
|
70
|
-
formatted = @formatter.format(tag, @time, record)
|
71
|
+
formatted = @formatter.instance.format(tag, @time, record)
|
71
72
|
assert_equal("file.test\t-\t-\t-\n", formatted)
|
72
73
|
end
|
73
74
|
|
@@ -81,7 +82,7 @@ class SprintfFormatterTest < ::Test::Unit::TestCase
|
|
81
82
|
tag = 'file.test'
|
82
83
|
record = {"array" => []}
|
83
84
|
|
84
|
-
formatted = @formatter.format(tag, @time, record)
|
85
|
+
formatted = @formatter.instance.format(tag, @time, record)
|
85
86
|
assert_equal("file.test\t-\n", formatted)
|
86
87
|
end
|
87
88
|
|
@@ -96,7 +97,7 @@ class SprintfFormatterTest < ::Test::Unit::TestCase
|
|
96
97
|
tag = 'file.test'
|
97
98
|
record = {}
|
98
99
|
|
99
|
-
formatted = @formatter.format(tag, @time, record)
|
100
|
+
formatted = @formatter.instance.format(tag, @time, record)
|
100
101
|
assert_equal("---\n", formatted)
|
101
102
|
end
|
102
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-formatter_sprintf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Toyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project: fluent-plugin-formatter_sprintf
|
122
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.6.11
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Fluentd Free formatter plugin, Use sprintf.
|