logstash-codec-pretty 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 06ace9f32df5a3db9252922653a60858b1ab5b58
4
+ data.tar.gz: d5080eb83d3637f1538a257fb0bcce0beb8b062c
5
+ SHA512:
6
+ metadata.gz: bd6ffe735a900c1d682aafd3eb0bae05f079dda41a5451a6c18bc179ceb854acbd34c5aa5dff14ca14269751977f8aaa824260d06f095ce5d8ddfe2bde789f5f
7
+ data.tar.gz: 470a9daf0ba8e2310f5c45fca5461e190d3ae654326af44011e8e045c00991eb38228b8ce7dfe615e7715c3649e450a6a563ba506d3f9b3a73908652bdd86ce7
@@ -0,0 +1,29 @@
1
+ ## 1.0.1
2
+ - Fix some documentation issues
3
+
4
+ ## 1.0.0
5
+ - Rename codec to `pretty` to better reflect its functionality.
6
+ ------------------------------------------------------------------
7
+
8
+ ## 3.0.2
9
+ - Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
10
+
11
+ ## 3.0.1
12
+ - Republish all the gems under jruby.
13
+ ## 3.0.0
14
+ - Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
15
+ # 2.0.7
16
+ - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
17
+ # 2.0.6
18
+ - New dependency requirements for logstash-core for the 5.0 release
19
+ ## 2.0.5
20
+ - monkey patch ActiveSupport in specs so awesome_print does not use a non existing method
21
+ ## 2.0.4
22
+ - remove LogStash::Timestamp coloring
23
+ ## 2.0.3
24
+ - Colorize LogStash::Timestamp as green
25
+ ## 2.0.0
26
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
27
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
28
+ - Dependency on logstash-core update to 2.0
29
+
@@ -0,0 +1,16 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Colin Surprenant (colinsurprenant)
6
+ * Jordan Sissel (jordansissel)
7
+ * João Duarte (jsvd)
8
+ * Kurt Hurtado (kurtado)
9
+ * Pier-Hugues Pellerin (ph)
10
+ * Richard Pijnenburg (electrical)
11
+ * Tal Levy (talevy)
12
+
13
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
14
+ Logstash, and you aren't on the list above and want to be, please let us know
15
+ and we'll make sure you're here. Contributions from folks like you are what make
16
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,98 @@
1
+ # Logstash Plugin
2
+
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-codec-pretty.svg)](https://travis-ci.org/logstash-plugins/logstash-codec-pretty)
4
+
5
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
+
7
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
8
+
9
+ ## Documentation
10
+
11
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
12
+
13
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
14
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
15
+
16
+ ## Need Help?
17
+
18
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
19
+
20
+ ## Developing
21
+
22
+ ### 1. Plugin Developement and Testing
23
+
24
+ #### Code
25
+ - To get started, you'll need JRuby with the Bundler gem installed.
26
+
27
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
28
+
29
+ - Install dependencies
30
+ ```sh
31
+ bundle install
32
+ ```
33
+
34
+ #### Test
35
+
36
+ - Update your dependencies
37
+
38
+ ```sh
39
+ bundle install
40
+ ```
41
+
42
+ - Run tests
43
+
44
+ ```sh
45
+ bundle exec rspec
46
+ ```
47
+
48
+ ### 2. Running your unpublished Plugin in Logstash
49
+
50
+ #### 2.1 Run in a local Logstash clone
51
+
52
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
53
+ ```ruby
54
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
55
+ ```
56
+ - Install plugin
57
+ ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
62
+ bin/plugin install --no-verify
63
+
64
+ ```
65
+ - Run Logstash with your plugin
66
+ ```sh
67
+ bin/logstash -e 'filter {awesome {}}'
68
+ ```
69
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
70
+
71
+ #### 2.2 Run in an installed Logstash
72
+
73
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
74
+
75
+ - Build your plugin gem
76
+ ```sh
77
+ gem build logstash-filter-awesome.gemspec
78
+ ```
79
+ - Install the plugin from the Logstash home
80
+ ```sh
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
87
+ ```
88
+ - Start Logstash and proceed to test the plugin
89
+
90
+ ## Contributing
91
+
92
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
93
+
94
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
95
+
96
+ It is more important to the community that you are able to contribute.
97
+
98
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,46 @@
1
+ :plugin: pretty
2
+ :type: codec
3
+
4
+ ///////////////////////////////////////////
5
+ START - GENERATED VARIABLES, DO NOT EDIT!
6
+ ///////////////////////////////////////////
7
+ :version: %VERSION%
8
+ :release_date: %RELEASE_DATE%
9
+ :changelog_url: %CHANGELOG_URL%
10
+ :include_path: ../../../../logstash/docs/include
11
+ ///////////////////////////////////////////
12
+ END - GENERATED VARIABLES, DO NOT EDIT!
13
+ ///////////////////////////////////////////
14
+
15
+ [id="plugins-{type}s-{plugin}"]
16
+
17
+ === Pretty codec plugin
18
+
19
+ include::{include_path}/plugin_header.asciidoc[]
20
+
21
+ ==== Description
22
+
23
+ The Pretty codec will pretty print your event data using
24
+ the Ruby Awesome Print library.
25
+
26
+
27
+ [id="plugins-{type}s-{plugin}-options"]
28
+ ==== Pretty Codec Configuration Options
29
+
30
+ [cols="<,<,<",options="header",]
31
+ |=======================================================================
32
+ |Setting |Input type|Required
33
+ | <<plugins-{type}s-{plugin}-metadata>> |<<boolean,boolean>>|No
34
+ |=======================================================================
35
+
36
+ &nbsp;
37
+
38
+ [id="plugins-{type}s-{plugin}-metadata"]
39
+ ===== `metadata`
40
+
41
+ * Value type is <<boolean,boolean>>
42
+ * Default value is `false`
43
+
44
+ Should the event's metadata be included in the output?
45
+
46
+
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+ require "logstash/codecs/base"
3
+
4
+ # The pretty codec will output your Logstash event data using
5
+ # the Ruby Awesome Print library.
6
+ #
7
+ class LogStash::Codecs::Pretty < LogStash::Codecs::Base
8
+ config_name "pretty"
9
+
10
+ # Should the event's metadata be included in the output?
11
+ config :metadata, :validate => :boolean, :default => false
12
+
13
+ # AWESOME_OPTIONS = {:color => {:logstash_timestamp => :green}}
14
+ # disabled options, awesome_print coloring option is buggy and only occurs once and it cannot be tested.
15
+ AWESOME_OPTIONS = {}
16
+
17
+ def register
18
+ require "awesome_print"
19
+ AwesomePrint.defaults = AWESOME_OPTIONS
20
+
21
+ if @metadata
22
+ @encoder = method(:encode_with_metadata)
23
+ else
24
+ @encoder = method(:encode_default)
25
+ end
26
+ end
27
+
28
+ public
29
+ def decode(data)
30
+ raise "Not implemented"
31
+ end # def decode
32
+
33
+ public
34
+ def encode(event)
35
+ @encoder.call(event)
36
+ end
37
+
38
+ def encode_default(event)
39
+ @on_event.call(event, event.to_hash.awesome_inspect + NL)
40
+ end # def encode_default
41
+
42
+ def encode_with_metadata(event)
43
+ @on_event.call(event, event.to_hash_with_metadata.awesome_inspect + NL)
44
+ end # def encode_with_metadata
45
+
46
+ end # class LogStash::Codecs::Pretty
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-codec-pretty'
4
+ s.version = '1.0.1'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "The codec will pretty print your output event data."
7
+ s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
8
+ s.authors = ["Elastic"]
9
+ s.email = 'info@elastic.co'
10
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = Dir["lib/**/*","spec/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"]
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
24
+
25
+ s.add_runtime_dependency 'awesome_print'
26
+
27
+ s.add_development_dependency 'logstash-devutils'
28
+ end
29
+
@@ -0,0 +1,44 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/codecs/pretty"
3
+ require "logstash/event"
4
+
5
+ describe LogStash::Codecs::Pretty do
6
+
7
+ # This is a necessary monkey patch that ensures that if ActiveSupport
8
+ # is defined, then the on_load method exists.
9
+ # The awesome_print gem uses this method to hook extra funcionality if
10
+ # ActiveSupport is loaded. Since some versions of ActiveSupport don't
11
+ # have the on_load method we must ensure this method exists.
12
+ # More information:
13
+ # * https://github.com/logstash-plugins/logstash-codec-pretty/issues/8
14
+ # * https://github.com/michaeldv/awesome_print/pull/206
15
+ before(:all) do
16
+ if defined?(ActiveSupport) && !ActiveSupport.respond_to?(:on_load)
17
+ module ActiveSupport
18
+ def self.on_load(*params); end
19
+ end
20
+ end
21
+ end
22
+
23
+ subject { LogStash::Codecs::Pretty.new }
24
+
25
+ context "#encode" do
26
+ it "should print beautiful hashes" do
27
+ subject.register
28
+
29
+ event = LogStash::Event.new({"what" => "ok", "who" => 2})
30
+ on_event = lambda { |e, d| expect(d.chomp).to eq(event.to_hash.awesome_inspect) }
31
+
32
+ subject.on_event(&on_event)
33
+ expect(on_event).to receive(:call).once.and_call_original
34
+
35
+ subject.encode(event)
36
+ end
37
+ end
38
+
39
+ context "#decode" do
40
+ it "should not be implemented" do
41
+ expect { subject.decode("data") }.to raise_error("Not implemented")
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-codec-pretty
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Elastic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '1.60'
19
+ - - "<="
20
+ - !ruby/object:Gem::Version
21
+ version: '2.99'
22
+ name: logstash-core-plugin-api
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.60'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: '2.99'
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: awesome_print
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ name: logstash-devutils
54
+ prerelease: false
55
+ type: :development
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
62
+ email: info@elastic.co
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - CHANGELOG.md
68
+ - CONTRIBUTORS
69
+ - Gemfile
70
+ - LICENSE
71
+ - NOTICE.TXT
72
+ - README.md
73
+ - docs/index.asciidoc
74
+ - lib/logstash/codecs/pretty.rb
75
+ - logstash-codec-pretty.gemspec
76
+ - spec/codecs/pretty_spec.rb
77
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
78
+ licenses:
79
+ - Apache License (2.0)
80
+ metadata:
81
+ logstash_plugin: 'true'
82
+ logstash_group: codec
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.8
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: The codec will pretty print your output event data.
103
+ test_files:
104
+ - spec/codecs/pretty_spec.rb