fluent-format 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 969f4553fc32823ac426e1f1aa7f8acd1b99c94f
4
+ data.tar.gz: c3a78502cd9a2592db22a8db7edc8c414c9457ce
5
+ SHA512:
6
+ metadata.gz: 18bb1683805a0e7dfa9297c44ca66949b279844eb9c0bee0fd31c30808add30d8af31f574c5b18c45a4aaade41f40791536360c15faf07a252f9fc72beaa62cb
7
+ data.tar.gz: 5bd3024ab31d88d630100a356fd71272a2c4cab4f22b2d91712b97d71ea5488b64d27c302e32e3ae5b7bfc64bee4457cf28060553847b7a5d0900ecbe81a652f
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /*.gem
2
+ ~*
3
+ #*
4
+ *~
5
+ .bundle
6
+ Gemfile.lock
7
+ .rbenv-version
8
+ vendor
9
+ doc/*
10
+ tmp/*
11
+ coverage
12
+ .yardoc
13
+ .ruby-version
14
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
5
+ gemfile:
6
+ - Gemfile
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.1 (2013/12/04)
2
+
3
+ First version
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Naotoshi Seo
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,38 @@
1
+ # fluent-format
2
+
3
+ A command line utility to format fluentd configuration beautifully
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fluent-format'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fluent-format
18
+
19
+ Run as
20
+
21
+ $ fluent-format -c fluentd.conf
22
+
23
+ ## ToDo
24
+
25
+ 1. write tests
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
34
+
35
+ ## Licenses
36
+
37
+ See [LICENSE](LICENSE)
38
+
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+ task :default => :spec
10
+
11
+ desc 'Open an irb session preloaded with the gem library'
12
+ task :console do
13
+ sh 'irb -rubygems -I lib'
14
+ end
15
+ task :c => :console
data/bin/fluent-format ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/fluent/format/cli'
3
+ Fluent::Format::CLI.start(ARGV)
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
4
+ require 'fluent/format/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fluent-format"
8
+ s.version = Fluent::Format::VERSION
9
+ s.authors = ["Naotoshi Seo"]
10
+ s.email = ["sonots@gmail.com"]
11
+ s.homepage = "https://github.com/sonots/fluent-format"
12
+ s.summary = "A command line utility to format fluentd configuration beautifully"
13
+ s.description = s.summary
14
+ s.licenses = ["MIT"]
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency "thor"
22
+ s.add_runtime_dependency "fluentd"
23
+
24
+ s.add_development_dependency "rake"
25
+ s.add_development_dependency "rspec"
26
+ s.add_development_dependency "pry"
27
+ s.add_development_dependency "pry-nav"
28
+ end
data/fluent.conf ADDED
@@ -0,0 +1,93 @@
1
+
2
+ ## built-in TCP input
3
+ ## $ echo <json> | fluent-cat <tag>
4
+ <source>
5
+ type forward
6
+ </source>
7
+
8
+ ## built-in UNIX socket input
9
+ #<source>
10
+ # type unix
11
+ #</source>
12
+
13
+ # HTTP input
14
+ # http://localhost:8888/<tag>?json=<json>
15
+ <source>
16
+ type http
17
+ port 8888
18
+ </source>
19
+
20
+ ## File input
21
+ ## read apache logs with tag=apache.access
22
+ #<source>
23
+ # type tail
24
+ # format apache
25
+ # path /var/log/httpd-access.log
26
+ # tag apache.access
27
+ #</source>
28
+
29
+ # Listen HTTP for monitoring
30
+ # http://localhost:24220/api/plugins
31
+ # http://localhost:24220/api/plugins?type=TYPE
32
+ # http://localhost:24220/api/plugins?tag=MYTAG
33
+ <source>
34
+ type monitor_agent
35
+ port 24220
36
+ </source>
37
+
38
+ # Listen DRb for debug
39
+ <source>
40
+ type debug_agent
41
+ port 24230
42
+ </source>
43
+
44
+
45
+ ## match tag=apache.access and write to file
46
+ #<match apache.access>
47
+ # type file
48
+ # path /var/log/fluent/access
49
+ #</match>
50
+
51
+ ## match tag=debug.** and dump to console
52
+ <match debug.**>
53
+ type stdout
54
+ </match>
55
+
56
+ # match tag=system.** and forward to another fluent server
57
+ <match system.**>
58
+ type forward
59
+ host 192.168.0.11
60
+ <secondary>
61
+ host 192.168.0.12
62
+ </secondary>
63
+ </match>
64
+
65
+ ## match tag=myapp.** and forward and write to file
66
+ #<match myapp.**>
67
+ # type copy
68
+ # <store>
69
+ # type forward
70
+ # host 192.168.0.13
71
+ # buffer_type file
72
+ # buffer_path /var/log/fluent/myapp-forward
73
+ # retry_limit 50
74
+ # flush_interval 10s
75
+ # </store>
76
+ # <store>
77
+ # type file
78
+ # path /var/log/fluent/myapp
79
+ # </store>
80
+ #</match>
81
+
82
+ ## match fluent's internal events
83
+ #<match fluent.**>
84
+ # type null
85
+ #</match>
86
+
87
+ ## match not matched logs and write to file
88
+ #<match **>
89
+ # type file
90
+ # path /var/log/fluent/else
91
+ # compress gz
92
+ #</match>
93
+
@@ -0,0 +1,2 @@
1
+ require_relative 'fluent/format/version'
2
+ require_relative 'fluent/format'
@@ -0,0 +1,42 @@
1
+ require 'fluent/load'
2
+
3
+ module Fluent
4
+ class Format
5
+ class << self
6
+ def format_config(dev)
7
+ config =
8
+ if dev.respond_to?(:read) # IO object
9
+ parse_config(dev, '-', '-')
10
+ else
11
+ read_config(dev)
12
+ end
13
+ indent_config(config)
14
+ end
15
+
16
+ private
17
+
18
+ # partial copy from lib/fluent/config.rb
19
+ def read_config(path)
20
+ File.open(path) {|io|
21
+ parse_config(io, File.basename(path), File.dirname(path))
22
+ }
23
+ end
24
+
25
+ # partial copy from lib/fluent/config.rb
26
+ def parse_config(io, fname, basepath=Dir.pwd)
27
+ if fname =~ /\.rb$/
28
+ Fluent::Config::DSL::Parser.parse(io, File.join(basepath, fname))
29
+ else
30
+ Fluent::Config.parse(io, fname, basepath)
31
+ end
32
+ end
33
+
34
+ # hmm, ugly workaround
35
+ def indent_config(conf)
36
+ lines = conf.to_s.split("\n")[1..-2] # remove <ROOT> and </ROOT>
37
+ lines = lines.map {|line| line[2..-1] } # remove heading 2 white spaces
38
+ lines.join("\n")
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,20 @@
1
+ require 'thor'
2
+ require_relative '../../fluent-format'
3
+
4
+ module Fluent
5
+ class Format
6
+ class CLI < Thor
7
+ default_command :start
8
+ desc "start", "Start fluent-format"
9
+ option :config, :aliases => ["-c"], :type => :string, :default => 'fluent.conf', :desc => 'Fluentd configuration file'
10
+ def start
11
+ config = @options[:config]
12
+ $log = Fluent::Log.new(STDERR, Fluent::Log::LEVEL_WARN)
13
+ puts Fluent::Format.format_config(config)
14
+ rescue => e
15
+ $log.error "#{e.class}: #{e}"
16
+ exit 1
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Fluent
2
+ class Format
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-format
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Naotoshi Seo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fluentd
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
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-nav
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A command line utility to format fluentd configuration beautifully
98
+ email:
99
+ - sonots@gmail.com
100
+ executables:
101
+ - fluent-format
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .rspec
107
+ - .travis.yml
108
+ - CHANGELOG.md
109
+ - Gemfile
110
+ - LICENSE
111
+ - README.md
112
+ - Rakefile
113
+ - bin/fluent-format
114
+ - fluent-format.gemspec
115
+ - fluent.conf
116
+ - lib/fluent-format.rb
117
+ - lib/fluent/format.rb
118
+ - lib/fluent/format/cli.rb
119
+ - lib/fluent/format/version.rb
120
+ homepage: https://github.com/sonots/fluent-format
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.0.3
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: A command line utility to format fluentd configuration beautifully
144
+ test_files: []