gelf.fitterpen 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0c273e38f1b89ee4713dae4dde8a57aa057addcb693e8665d4636b548c4fe363
4
+ data.tar.gz: 790e29ccafba2ce08955729f6d53326f1e7b16db872a56da8ee4256b739f97c6
5
+ SHA512:
6
+ metadata.gz: 03b34ca4e676b169a86b6918214a8b7560f953e348c98493a559d5ac3711b292397be41b1046482366ad03cef08d9b01cf10c94677e5ebd64a5624198ffc1d4b
7
+ data.tar.gz: 9411c770f4926769cb5f19473e2069be5a5dc9fc585dc86c2154fb6a0082e9ec120df430f6133d093ba3b4ad6c5266a073f57a4ed2a7fd0dd325ae4f8733fc31
data/.gemtest ADDED
File without changes
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 2.2.0
6
+ - 2.3.0
7
+ - 2.4.0
8
+ - jruby-19mode
9
+ deploy:
10
+ provider: rubygems
11
+ api_key:
12
+ secure: Pm1yAqo2ldet/Fd2jK5dKZkDNmyx5KkYtViL+eOR4Rxs82dwqOcCSyrBL6BOzuRfJtpjgXUX6FDapKgLDYW/2EDW8mmiciOL0WLzxYQsmJXcerJeUl2tTeFKpyEf+8aaDQpAlsK0m1dPmQjCJF9MWsa7m3oshm3mJ1VITY90chM=
13
+ gem: gelf
14
+ gemspec: gelf.gemspec
15
+ on:
16
+ tags: true
17
+ repo: graylog-labs/gelf-rb
data/CHANGELOG ADDED
@@ -0,0 +1,54 @@
1
+ 3.0.0, 2016-08-21
2
+ + Overhaul TCP support
3
+ + Include automatic support for Celluloid::IO if available
4
+ + Add TLS support to TCP transport
5
+ - Remove support for ancient Rubygems versions
6
+ - Remove support for Ruby 1.9.2 (1.9.3 works!)
7
+ - Remove already-deprecated `host` and `port` methods on GELF::Notifier
8
+
9
+ 2.0.0, 2016-02-02
10
+ + Added GELF TCP support.
11
+
12
+ 1.3.2, 2011-12-02:
13
+ * support for rubygems-test.
14
+ * rescue from more network errors.
15
+
16
+ 1.3.1, 2011-10-28:
17
+ + allow to rescue from network errors.
18
+
19
+ 1.3.0, 2011-07-27:
20
+ + allow to set timestamp manually.
21
+
22
+ 1.2.0.beta1, 2011-05-23:
23
+ + compatibility with GELF specification 1.0:
24
+ * requires modern graylog2-server and graylog2-web-interface;
25
+ + Notifier#default_options, Notifier#default_options=;
26
+ + severity (level) threshold;
27
+ + automatically set 'file', 'line' and 'timestamp' fields;
28
+ + wrappers for GELF::Notifier#notify with severity:
29
+ + GELF::Notifier.debug
30
+ + GELF::Notifier.info
31
+ + GELF::Notifier.warn
32
+ + GELF::Notifier.error
33
+ + GELF::Notifier.fatal
34
+ + GELF::Notifier.unknown
35
+ + full compatibility with Ruby Logger and other loggers:
36
+ + GELF::Logger#fatal { "Argument 'foo' not given." }
37
+ + GELF::Logger#error "Argument #{ @foo } mismatch."
38
+ + GELF::Logger#info('initialize') { "Initializing..." }
39
+ + GELF::Logger#add(GELF::FATAL) { 'Fatal error!' }
40
+ + GELF::Logger#close
41
+ + GELF::Logger#level = GELF::INFO
42
+ + allow to change severity mapping;
43
+ + send messages to receivers in round-robin;
44
+ * GELF::Notifier#host and #port are attr_readers now and deprecated (were attr_accessor);
45
+ + allow to disable file and line collection (GELF::Notifier#collect_file_and_line = false);
46
+ - deprecated Gelf class removed.
47
+
48
+ 1.0.2, 2010-11-29:
49
+ 1.0.1, 2010-11-29:
50
+ - added more tests for chunking in attempt to locate not existing bug.
51
+
52
+ 1.0.0, 2010-11-10:
53
+ + initial stable version;
54
+ * deprecated Gelf class is still there.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1 @@
1
+ Please follow [the instructions on graylog.org](https://www.graylog.org/contributing-to-graylog/).
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "shoulda", "~> 2.11.3"
5
+ gem "jeweler", "~> 2.1.1"
6
+ # Because of a dependency chain jeweler->github_api->oauth2->rack,
7
+ # pin the version: Rack 2.0.x doesn't work on < Ruby 2.2
8
+ gem 'rack', '< 2.0'
9
+ gem "mocha", "~> 1.1.0"
10
+ gem "test-unit", "~> 3.2.0"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ faraday (0.9.2)
9
+ multipart-post (>= 1.2, < 3)
10
+ git (1.3.0)
11
+ github_api (0.14.5)
12
+ addressable (~> 2.4.0)
13
+ descendants_tracker (~> 0.0.4)
14
+ faraday (~> 0.8, < 0.10)
15
+ hashie (>= 3.4)
16
+ oauth2 (~> 1.0)
17
+ hashie (3.4.4)
18
+ highline (1.7.8)
19
+ jeweler (2.1.1)
20
+ builder
21
+ bundler (>= 1.0)
22
+ git (>= 1.2.5)
23
+ github_api
24
+ highline (>= 1.6.15)
25
+ nokogiri (>= 1.5.10)
26
+ rake
27
+ rdoc
28
+ semver
29
+ json (1.8.6)
30
+ json (1.8.6-java)
31
+ jwt (1.5.4)
32
+ metaclass (0.0.4)
33
+ mini_portile2 (2.1.0)
34
+ mocha (1.1.0)
35
+ metaclass (~> 0.0.1)
36
+ multi_json (1.12.1)
37
+ multi_xml (0.5.5)
38
+ multipart-post (2.0.0)
39
+ nokogiri (1.6.8)
40
+ mini_portile2 (~> 2.1.0)
41
+ pkg-config (~> 1.1.7)
42
+ nokogiri (1.6.8-java)
43
+ oauth2 (1.2.0)
44
+ faraday (>= 0.8, < 0.10)
45
+ jwt (~> 1.0)
46
+ multi_json (~> 1.3)
47
+ multi_xml (~> 0.5)
48
+ rack (>= 1.2, < 3)
49
+ pkg-config (1.1.7)
50
+ power_assert (0.3.0)
51
+ rack (1.6.4)
52
+ rake (11.2.2)
53
+ rdoc (4.2.2)
54
+ json (~> 1.4)
55
+ semver (1.0.1)
56
+ shoulda (2.11.3)
57
+ test-unit (3.2.1)
58
+ power_assert
59
+ thread_safe (0.3.5)
60
+ thread_safe (0.3.5-java)
61
+
62
+ PLATFORMS
63
+ java
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ jeweler (~> 2.1.1)
68
+ mocha (~> 1.1.0)
69
+ rack (< 2.0)
70
+ shoulda (~> 2.11.3)
71
+ test-unit (~> 3.2.0)
72
+
73
+ BUNDLED WITH
74
+ 1.14.6
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010-2016 Lennart Koopmann, Alexey Palazhchenko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ ## GELF Ruby library
2
+
3
+ This is the new GELF gem written by Alexey Palazhchenko. It is based on the old gem by Lennart Koopmann and allows you to send GELF messages to Graylog or Logstash instances. See the [GELF specification](http://docs.graylog.org/en/stable/pages/gelf.html) for more information about GELF and [RDoc](http://rdoc.info/github/graylog-labs/gelf-rb/master/frames) for API documentation.
4
+
5
+ Tested with Ruby 1.9, 2.0, 2.1, 2.2, 2.3 and 2.4.
6
+
7
+ [![Build Status](https://travis-ci.org/graylog-labs/gelf-rb.svg?branch=master)](https://travis-ci.org/graylog-labs/gelf-rb)
8
+ [![Code Climate](https://codeclimate.com/github/graylog-labs/gelf-rb/badges/gpa.svg)](https://codeclimate.com/github/graylog-labs/gelf-rb)
9
+
10
+ ## Usage
11
+ ### Gelf::Notifier
12
+
13
+ This allows you to sent arbitary messages via UDP to Graylog.
14
+
15
+ n = GELF::Notifier.new("localhost", 12201)
16
+
17
+ # Send with custom attributes and an additional parameter "foo"
18
+ n.notify!(:short_message => "foo", :full_message => "something here\n\nbacktrace?!", :_foo => "bar")
19
+
20
+ # Pass any object that responds to .to_hash
21
+ n.notify!(Exception.new)
22
+
23
+ The recommended default is to send via UDP but you can choose to send via TCP like this:
24
+
25
+ n = GELF::Notifier.new("127.0.0.1", 12201, "LAN", { :protocol => GELF::Protocol::TCP })
26
+
27
+ Note that the `LAN` or `WAN` option is ignored for TCP because no chunking happens. (Read below for more information.)
28
+
29
+ ### Gelf::Logger
30
+
31
+ The Gelf::Logger is compatible with the standard Ruby Logger interface and can be used interchangeably.
32
+ Under the hood it uses Gelf::Notifier to send log messages via UDP to Graylog.
33
+
34
+ logger = GELF::Logger.new("localhost", 12201, "WAN", { :facility => "appname" })
35
+
36
+ logger.debug "foobar"
37
+ logger.info "foobar"
38
+ logger.warn "foobar"
39
+ logger.error "foobar"
40
+ logger.fatal "foobar"
41
+
42
+ logger << "foobar"
43
+
44
+ Then `WAN` or `LAN` option influences the UDP chunk size depending on if you send in your own
45
+ network (LAN) or on a longer route (i.e. through the internet) and should be set accordingly.
46
+
47
+ Since it's compatible with the Logger interface, you can also use it in your Rails application:
48
+
49
+ # config/environments/production.rb
50
+ config.logger = GELF::Logger.new("localhost", 12201, "WAN", { :facility => "appname" })
51
+
52
+ ### Note on Patches/Pull Requests
53
+
54
+ * Fork the project.
55
+ * Make your feature addition or bug fix.
56
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
57
+ * Commit, do not mess with rakefile, version, or history.
58
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
59
+ * Send me a pull request. Bonus points for topic branches.
60
+
61
+ ## Copyright
62
+
63
+ Copyright (c) 2010-2016 Lennart Koopmann and Alexey Palazhchenko. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'ci/reporter/rake/test_unit'
5
+ rescue LoadError
6
+ # nothing
7
+ end
8
+
9
+ begin
10
+ require 'jeweler'
11
+
12
+ Jeweler::Tasks.new do |gem|
13
+ gem.name = "gelf"
14
+ gem.summary = 'Library to send GELF messages to Graylog logging server.'
15
+ gem.description = 'Library to send GELF messages to Graylog logging server. Supports plain-text, GELF messages and exceptions via UDP and TCP.'
16
+ gem.email = "mail@marcusilgner.com"
17
+ gem.homepage = "http://github.com/Graylog2/gelf-rb"
18
+ gem.authors = ["Alexey Palazhchenko", "Lennart Koopmann", "Zac Sprackett", "Marcus Ilgner"]
19
+ gem.add_dependency "json"
20
+ gem.licenses = ["MIT"]
21
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
+ end
23
+ rescue LoadError => e
24
+ puts e
25
+ abort "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
26
+ end
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ begin
38
+ require 'rcov/rcovtask'
39
+ Rcov::RcovTask.new do |test|
40
+ test.libs << 'test'
41
+ test.pattern = 'test/**/test_*.rb'
42
+ test.rcov_opts << '--exclude gem'
43
+ test.verbose = true
44
+ end
45
+ rescue LoadError => e
46
+ task :rcov do
47
+ puts e
48
+ abort "rcov is not available. Run: gem install rcov"
49
+ end
50
+ end
51
+
52
+ #require 'rake/rdoctask'
53
+ #Rake::RDocTask.new do |rdoc|
54
+ # version = File.exist?('VERSION') ? File.read('VERSION') : ""
55
+ #
56
+ # rdoc.rdoc_dir = 'rdoc'
57
+ # rdoc.title = "gelf #{version}"
58
+ # rdoc.rdoc_files.include('README*')
59
+ # rdoc.rdoc_files.include('lib/**/*.rb')
60
+ #end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.1.0
@@ -0,0 +1,39 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ puts "Loading..."
4
+
5
+ require 'benchmark'
6
+ require 'rubygems'
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
9
+ require 'gelf'
10
+
11
+ puts "Generating random data..."
12
+ srand(1)
13
+ RANDOM_DATA = ('A'..'z').to_a
14
+ k3_message = (1..3*1024).map { RANDOM_DATA[rand(RANDOM_DATA.count)] }.join
15
+
16
+ TARGET_HOST = 'localhost'
17
+ TARGET_PORT = 12201
18
+ DEFAULT_OPTIONS = { '_host' => 'localhost' }
19
+ TIMES = 5000
20
+
21
+ SHORT_HASH = { 'short_message' => 'message' }
22
+ LONG_HASH = { 'short_message' => 'message', 'long_message' => k3_message }
23
+
24
+
25
+ notifier_lan = GELF::Notifier.new(TARGET_HOST, TARGET_PORT, 'LAN', DEFAULT_OPTIONS)
26
+ notifier_wan = GELF::Notifier.new(TARGET_HOST, TARGET_PORT, 'WAN', DEFAULT_OPTIONS)
27
+
28
+ # to create mongo collections, etc.
29
+ notifier_lan.notify!(LONG_HASH)
30
+ sleep(5)
31
+
32
+ puts "Sending #{TIMES} notifications...\n"
33
+ tms = Benchmark.bm(25) do |b|
34
+ b.report('lan, short data, 1 chunk ') { TIMES.times { notifier_lan.notify!(SHORT_HASH) } }
35
+ sleep(5)
36
+ b.report('lan, long data, 1 chunk ') { TIMES.times { notifier_lan.notify!(LONG_HASH) } }
37
+ sleep(5)
38
+ b.report('wan, long data, 2 chunks') { TIMES.times { notifier_wan.notify!(LONG_HASH) } }
39
+ end
data/gelf.gemspec ADDED
@@ -0,0 +1,79 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: gelf 3.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "gelf.fitterpen"
9
+ s.version = "3.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Alexey Palazhchenko", "Lennart Koopmann", "Zac Sprackett", "Marcus Ilgner"]
14
+ s.date = "2018-09-05"
15
+ s.description = "Library to send GELF messages to Graylog logging server. Supports plain-text, GELF messages and exceptions via UDP and TCP."
16
+ s.email = "mail@marcusilgner.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".gemtest",
23
+ ".travis.yml",
24
+ "CHANGELOG",
25
+ "CONTRIBUTING.md",
26
+ "Gemfile",
27
+ "Gemfile.lock",
28
+ "LICENSE",
29
+ "README.md",
30
+ "Rakefile",
31
+ "VERSION",
32
+ "benchmarks/notifier.rb",
33
+ "gelf.gemspec",
34
+ "lib/gelf.rb",
35
+ "lib/gelf/logger.rb",
36
+ "lib/gelf/notifier.rb",
37
+ "lib/gelf/severity.rb",
38
+ "lib/gelf/transport/tcp.rb",
39
+ "lib/gelf/transport/tcp_tls.rb",
40
+ "lib/gelf/transport/udp.rb",
41
+ "test/helper.rb",
42
+ "test/test_logger.rb",
43
+ "test/test_notifier.rb",
44
+ "test/test_ruby_sender.rb",
45
+ "test/test_severity.rb"
46
+ ]
47
+ s.homepage = "https://github.com/graylog-labs/gelf-rb"
48
+ s.licenses = ["MIT"]
49
+ s.rubygems_version = "2.5.1"
50
+ s.summary = "Library to send GELF messages to Graylog logging server."
51
+
52
+ if s.respond_to? :specification_version then
53
+ s.specification_version = 4
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ s.add_development_dependency(%q<shoulda>, ["~> 2.11.3"])
57
+ s.add_development_dependency(%q<jeweler>, ["~> 2.1.1"])
58
+ s.add_development_dependency(%q<rack>, ["< 2.0"])
59
+ s.add_development_dependency(%q<mocha>, ["~> 1.1.0"])
60
+ s.add_development_dependency(%q<test-unit>, ["~> 3.2.0"])
61
+ s.add_runtime_dependency(%q<json>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
64
+ s.add_dependency(%q<jeweler>, ["~> 2.1.1"])
65
+ s.add_dependency(%q<rack>, ["< 2.0"])
66
+ s.add_dependency(%q<mocha>, ["~> 1.1.0"])
67
+ s.add_dependency(%q<test-unit>, ["~> 3.2.0"])
68
+ s.add_dependency(%q<json>, [">= 0"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
72
+ s.add_dependency(%q<jeweler>, ["~> 2.1.1"])
73
+ s.add_dependency(%q<rack>, ["< 2.0"])
74
+ s.add_dependency(%q<mocha>, ["~> 1.1.0"])
75
+ s.add_dependency(%q<test-unit>, ["~> 3.2.0"])
76
+ s.add_dependency(%q<json>, [">= 0"])
77
+ end
78
+ end
79
+
@@ -0,0 +1,64 @@
1
+ module GELF
2
+ # Methods for compatibility with Ruby Logger.
3
+ module LoggerCompatibility
4
+
5
+ attr_accessor :formatter
6
+
7
+ # Use it like Logger#add... or better not to use at all.
8
+ def add(level, message = nil, progname = nil, &block)
9
+ progname ||= default_options['facility']
10
+ message ||= block.call unless block.nil?
11
+
12
+ if message.nil?
13
+ message = progname
14
+ progname = default_options['facility']
15
+ end
16
+
17
+ message_hash = { 'facility' => progname }
18
+
19
+ if message.is_a?(Hash)
20
+ message.each do |key, value|
21
+ message_hash[key.to_s] = value.to_s
22
+ end
23
+ else
24
+ message_hash['short_message'] = message.to_s
25
+ end
26
+
27
+ if message.is_a?(Exception)
28
+ message_hash.merge!(self.class.extract_hash_from_exception(message))
29
+ end
30
+
31
+ if message_hash.key?('short_message') && !message_hash['short_message'].empty?
32
+ notify_with_level(level, message_hash)
33
+ end
34
+ end
35
+
36
+ # Redefines methods in +Notifier+.
37
+ GELF::Levels.constants.each do |const|
38
+ method_name = const.downcase
39
+
40
+ define_method(method_name) do |progname=nil, &block|
41
+ const_level = GELF.const_get(const)
42
+ add(const_level, nil, progname, &block)
43
+ end
44
+
45
+ define_method("#{method_name}?") do
46
+ const_level = GELF.const_get(const)
47
+ const_level >= level
48
+ end
49
+ end
50
+
51
+ def <<(message)
52
+ notify_with_level(GELF::UNKNOWN, 'short_message' => message)
53
+ end
54
+ end
55
+
56
+ # Graylog2 notifier, compatible with Ruby Logger.
57
+ # You can use it with Rails like this:
58
+ # config.logger = GELF::Logger.new("localhost", 12201, "WAN", { :facility => "appname" })
59
+ # config.colorize_logging = false
60
+ class Logger < Notifier
61
+ include LoggerCompatibility
62
+ end
63
+
64
+ end