loggerstash 0.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4f2945f9572e10047201fc9b3ac4422923e8b58b
4
- data.tar.gz: 7652bff72a6bb80fe20fcfd1d6ffe7c55679bc8f
2
+ SHA256:
3
+ metadata.gz: 2d39439e76c2953faa8dace7d2fe630d79f9e492ff206ebc1631417993fd191a
4
+ data.tar.gz: 0bf51ec28020039b3ae864a03be3403caa7c2d84c73b236f003184827c37a1c2
5
5
  SHA512:
6
- metadata.gz: 3c2c0be50c3a3706dca83b4e7b26c549f920c41c88fb73d0e397c1b5aa5ff99d9d89057d15d5a2adff18b3f4043b835e8a4a4474c69dc34e78a712ff3b20114e
7
- data.tar.gz: 81d0b3da5b0ccabd57f6beaa74b43b993f33b11a23a1b2b9bb9aa3b96362043aca95626d3c0bf71ce0ad52021ce74fac3e0e1627a8bb95cca186f175098b3e6d
6
+ metadata.gz: efe6185c0427be6761ae1661e64d288667d91e6cb00fa1fbb276d942216fdd7e14ada8d8122523b64c51d542ca8e26303b1ec94d3d978122ca452371b90d9e16
7
+ data.tar.gz: 393bfa2235d52e84fac15bab45229e80c9e5b3264e67d23078f09540a47343102d7c4e3e2cf87f7242d89d2e0bf5574e4b456f78cccde39cec7a74aae72c1da5
data/.editorconfig ADDED
@@ -0,0 +1,7 @@
1
+ [*.rb]
2
+ indent_style = space
3
+ indent_size = 2
4
+ end_of_line = lf
5
+ insert_final_newline = true
6
+ charset = utf-8
7
+ trim_trailing_whitespace = true
@@ -0,0 +1,50 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
8
+ - main
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - 2.5
18
+ - 2.6
19
+ - 2.7
20
+ - 3.0
21
+
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+
25
+ - name: Setup ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
30
+
31
+ - name: Lint
32
+ run: bundle exec rubocop
33
+
34
+ - name: Tests
35
+ run: bundle exec rake test
36
+
37
+ publish:
38
+ if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
39
+ needs: build
40
+ runs-on: ubuntu-latest
41
+
42
+ steps:
43
+ - uses: actions/checkout@v2
44
+
45
+ - name: Release Gem
46
+ uses: discourse/publish-rubygems-action@v2-beta
47
+ env:
48
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
49
+ GIT_EMAIL: team@discourse.org
50
+ GIT_NAME: discoursebot
data/.gitignore CHANGED
@@ -1,7 +1,2 @@
1
1
  Gemfile.lock
2
- /pkg
3
- /doc
4
- /.yardoc
5
2
  /coverage
6
- /.bundle
7
- /tmp
data/.rubocop.yml CHANGED
@@ -1,116 +1,2 @@
1
- AllCops:
2
- TargetRubyVersion: 2.4
3
- DisabledByDefault: true
4
- Exclude:
5
- - 'db/schema.rb'
6
- - 'bundle/**/*'
7
- - 'vendor/**/*'
8
- - 'node_modules/**/*'
9
- - 'public/**/*'
10
-
11
- # Prefer &&/|| over and/or.
12
- Style/AndOr:
13
- Enabled: true
14
-
15
- # Do not use braces for hash literals when they are the last argument of a
16
- # method call.
17
- Style/BracesAroundHashParameters:
18
- Enabled: true
19
-
20
- # Align `when` with `case`.
21
- Layout/CaseIndentation:
22
- Enabled: true
23
-
24
- # Align comments with method definitions.
25
- Layout/CommentIndentation:
26
- Enabled: true
27
-
28
- # No extra empty lines.
29
- Layout/EmptyLines:
30
- Enabled: true
31
-
32
- # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
33
- Style/HashSyntax:
34
- Enabled: true
35
-
36
- # Two spaces, no tabs (for indentation).
37
- Layout/IndentationWidth:
38
- Enabled: true
39
-
40
- Layout/SpaceAfterColon:
41
- Enabled: true
42
-
43
- Layout/SpaceAfterComma:
44
- Enabled: true
45
-
46
- Layout/SpaceAroundEqualsInParameterDefault:
47
- Enabled: true
48
-
49
- Layout/SpaceAroundKeyword:
50
- Enabled: true
51
-
52
- Layout/SpaceAroundOperators:
53
- Enabled: true
54
-
55
- Layout/SpaceBeforeFirstArg:
56
- Enabled: true
57
-
58
- # Defining a method with parameters needs parentheses.
59
- Style/MethodDefParentheses:
60
- Enabled: true
61
-
62
- # Use `foo {}` not `foo{}`.
63
- Layout/SpaceBeforeBlockBraces:
64
- Enabled: true
65
-
66
- # Use `foo { bar }` not `foo {bar}`.
67
- Layout/SpaceInsideBlockBraces:
68
- Enabled: true
69
-
70
- # Use `{ a: 1 }` not `{a:1}`.
71
- Layout/SpaceInsideHashLiteralBraces:
72
- Enabled: true
73
-
74
- Layout/SpaceInsideParens:
75
- Enabled: true
76
-
77
- # Detect hard tabs, no hard tabs.
78
- Layout/Tab:
79
- Enabled: true
80
-
81
- # Blank lines should not have any spaces.
82
- Layout/TrailingBlankLines:
83
- Enabled: true
84
-
85
- # No trailing whitespace.
86
- Layout/TrailingWhitespace:
87
- Enabled: true
88
-
89
- Lint/Debugger:
90
- Enabled: true
91
-
92
- Layout/BlockAlignment:
93
- Enabled: true
94
-
95
- # Align `end` with the matching keyword or starting expression except for
96
- # assignments, where it should be aligned with the LHS.
97
- Layout/EndAlignment:
98
- Enabled: true
99
- EnforcedStyleAlignWith: variable
100
-
101
- # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
102
- Lint/RequireParentheses:
103
- Enabled: true
104
-
105
- Lint/ShadowingOuterLocalVariable:
106
- Enabled: true
107
-
108
- Layout/MultilineMethodCallIndentation:
109
- Enabled: true
110
- EnforcedStyle: indented
111
-
112
- Layout/AlignHash:
113
- Enabled: true
114
-
115
- Bundler/OrderedGems:
116
- Enabled: false
1
+ inherit_gem:
2
+ rubocop-discourse: default.yml
data/CONTRIBUTING.md CHANGED
@@ -1,5 +1,5 @@
1
1
  * If, heaven forbid, you find a security vulnerability, please e-mail
2
- `matt.palmer@discourse.org`.
2
+ `security@discourse.org`.
3
3
 
4
4
  * If you have found a discrepancy in documented and observed behaviour, that
5
5
  is a bug. Feel free to [report it as an
data/README.md CHANGED
@@ -135,7 +135,7 @@ conduct](CODE_OF_CONDUCT.md).
135
135
  Unless otherwise stated, everything in this repo is covered by the following
136
136
  copyright notice:
137
137
 
138
- Copyright (C) 2018 Civilized Discourse Construction Kit, Inc.
138
+ Copyright (C) 2018-2021 Civilized Discourse Construction Kit, Inc.
139
139
 
140
140
  This program is free software: you can redistribute it and/or modify it
141
141
  under the terms of the GNU General Public License version 3, as
data/lib/loggerstash.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logstash_writer'
2
4
  require 'thread'
3
5
 
@@ -14,31 +16,29 @@ class Loggerstash
14
16
  #
15
17
  class AlreadyRunningError < Error; end
16
18
 
17
- # Set the formatter proc to a new proc.
18
- #
19
- # The passed in proc must take four arguments: `severity`, `timestamp`,
20
- # `progname` and `message`. `timestamp` is a `Time`, all over arguments
21
- # are `String`s, and `progname` can possibly be `nil`. It must return a
22
- # Hash containing the parameters you wish to send to logstash.
23
- #
24
- attr_writer :formatter
25
-
26
19
  # A new Loggerstash!
27
20
  #
28
21
  # @param logstash_server [String] an address:port, hostname:port, or srvname
29
22
  # to which a `json_lines` logstash connection can be made.
23
+ #
30
24
  # @param metrics_registry [Prometheus::Client::Registry] where the metrics
31
25
  # which are used by the underlying `LogstashWriter` should be registered,
32
26
  # for later presentation by the Prometheus client.
27
+ #
33
28
  # @param formatter [Proc] a formatting proc which takes the same arguments
34
29
  # as the standard `Logger` formatter, but rather than emitting a string,
35
30
  # it should pass back a Hash containing all the fields you wish to send
36
31
  # to logstash.
32
+ #
37
33
  # @param logstash_writer [LogstashWriter] in the event that you've already
38
34
  # got a LogstashWriter instance configured, you can pass it in here. Note
39
35
  # that any values you've set for logstash_server and metrics_registry
40
36
  # will be ignored.
41
37
  #
38
+ # @param logger [Logger] passed to the LogstashWriter we create. May or
39
+ # may not, itself, be attached to the Loggerstash for forwarding to
40
+ # logstash (Logception!).
41
+ #
42
42
  def initialize(logstash_server:, metrics_registry: nil, formatter: nil, logstash_writer: nil, logger: nil)
43
43
  @logstash_server = logstash_server
44
44
  @metrics_registry = metrics_registry
@@ -61,20 +61,21 @@ class Loggerstash
61
61
  # benefit from the attachment; that's up to you to ensure.
62
62
  #
63
63
  def attach(obj)
64
+ run_writer
65
+
64
66
  @op_mutex.synchronize do
65
- obj.instance_variable_set(:@loggerstash, self)
67
+ obj.instance_variable_set(:@logstash_writer, @logstash_writer)
68
+ obj.instance_variable_set(:@loggerstash_formatter, @formatter)
66
69
 
67
70
  if obj.is_a?(Module)
68
71
  obj.prepend(Mixin)
69
72
  else
70
73
  obj.singleton_class.prepend(Mixin)
71
74
  end
72
-
73
- run_writer
74
75
  end
75
76
  end
76
77
 
77
- %i{logstash_server metrics_registry}.each do |sym|
78
+ %i{formatter logger logstash_server metrics_registry}.each do |sym|
78
79
  define_method(:"#{sym}=") do |v|
79
80
  @op_mutex.synchronize do
80
81
  if @logstash_writer
@@ -86,68 +87,25 @@ class Loggerstash
86
87
  end
87
88
  end
88
89
 
89
- # Send a logger message to logstash.
90
- #
91
- # @private
92
- #
93
- def log_message(s, t, p, m)
94
- @op_mutex.synchronize do
95
- if @logstash_writer.nil?
96
- #:nocov:
97
- run_writer
98
- #:nocov:
99
- end
100
-
101
- @logstash_writer.send_event((@formatter || default_formatter).call(s, t, p, m))
102
- end
103
- end
104
-
105
90
  private
106
91
 
107
92
  # Do the needful to get the writer going.
108
93
  #
109
- # This will error out unless the @op_mutex is held at the time the
110
- # method is called; we can't acquire it ourselves because some calls
111
- # to run_writer already need to hold the mutex.
112
- #
113
94
  def run_writer
114
- unless @op_mutex.owned?
115
- #:nocov:
116
- raise RuntimeError,
117
- "Must call run_writer while holding @op_mutex"
118
- #:nocov:
119
- end
120
-
121
- if @logstash_writer.nil?
122
- {}.tap do |opts|
123
- opts[:server_name] = @logstash_server
124
- if @metrics_registry
125
- opts[:metrics_registry] = @metrics_registry
126
- end
127
- if @logger
128
- opts[:logger] = @logger
95
+ @op_mutex.synchronize do
96
+ if @logstash_writer.nil?
97
+ {}.tap do |opts|
98
+ opts[:server_name] = @logstash_server
99
+ if @metrics_registry
100
+ opts[:metrics_registry] = @metrics_registry
101
+ end
102
+ if @logger
103
+ opts[:logger] = @logger
104
+ end
105
+
106
+ @logstash_writer = LogstashWriter.new(**opts)
107
+ @logstash_writer.start!
129
108
  end
130
-
131
- @logstash_writer = LogstashWriter.new(**opts)
132
- @logstash_writer.run
133
- end
134
- end
135
- end
136
-
137
- # Mangle the standard sev/time/prog/msg set into a minimal logstash
138
- # event.
139
- #
140
- def default_formatter
141
- @default_formatter ||= ->(s, t, p, m) do
142
- {
143
- "@timestamp": t.utc.strftime("%FT%T.%NZ"),
144
- "@metadata": { event_type: "loggerstash" },
145
- message: m,
146
- severity_name: s.downcase,
147
- hostname: Socket.gethostname,
148
- pid: $$,
149
- }.tap do |ev|
150
- ev[:progname] = p if p
151
109
  end
152
110
  end
153
111
  end
@@ -155,26 +113,41 @@ class Loggerstash
155
113
  # The methods needed to turn any Logger into a Loggerstash Logger.
156
114
  #
157
115
  module Mixin
116
+ attr_writer :logstash_writer, :loggerstash_formatter
117
+
158
118
  private
159
119
 
160
120
  # Hooking into this specific method may seem... unorthodox, but
161
121
  # it seemingly has an extremely stable interface and is the most
162
122
  # appropriate place to inject ourselves.
123
+ #
163
124
  def format_message(s, t, p, m)
164
- loggerstash.log_message(s, t, p, m)
125
+ loggerstash_log_message(s, t, p, m)
165
126
 
166
127
  super
167
128
  end
168
129
 
169
- # Find where our associated Loggerstash object is being held captive.
130
+ # Send a logger message to logstash.
131
+ #
132
+ def loggerstash_log_message(s, t, p, m)
133
+ logstash_writer.send_event(loggerstash_formatter.call(s, t, p, m))
134
+ end
135
+
136
+ # The current formatter for logstash-destined messages.
137
+ #
138
+ def loggerstash_formatter
139
+ @loggerstash_formatter ||= self.class.ancestors.find { |m| m.instance_variable_defined?(:@loggerstash_formatter) }.instance_variable_get(:@loggerstash_formatter) || default_loggerstash_formatter
140
+ end
141
+
142
+ # Find the relevant logstash_writer for this Logger.
170
143
  #
171
144
  # We're kinda reimplementing Ruby's method lookup logic here, but there's
172
145
  # no other way to store our object *somewhere* in the object + class
173
146
  # hierarchy and still be able to get at it from a module (class variables
174
- # don't like being accessed from modules).
175
- #
176
- def loggerstash
177
- ([self] + self.class.ancestors).find { |m| m.instance_variable_defined?(:@loggerstash) }.instance_variable_get(:@loggerstash).tap do |ls|
147
+ # don't like being accessed from modules). This is necessary because you
148
+ # can attach Loggerstash to the Logger class, not just to an instance.
149
+ def logstash_writer
150
+ @logstash_writer ||= self.class.ancestors.find { |m| m.instance_variable_defined?(:@logstash_writer) }.instance_variable_get(:@logstash_writer).tap do |ls|
178
151
  if ls.nil?
179
152
  #:nocov:
180
153
  raise RuntimeError,
@@ -183,5 +156,53 @@ class Loggerstash
183
156
  end
184
157
  end
185
158
  end
159
+
160
+ # Mangle the standard sev/time/prog/msg set into a logstash event.
161
+ #
162
+ # Caller information is a https://www.rubydoc.info/stdlib/core/Thread/Backtrace/Location
163
+ def default_loggerstash_formatter
164
+ ->(s, t, p, m) do
165
+ caller = caller_locations.find { |loc| ! [__FILE__, logger_filename].include? loc.absolute_path }
166
+
167
+ {
168
+ "@timestamp": t.utc.strftime("%FT%T.%NZ"),
169
+ "@metadata": { event_type: "loggerstash" },
170
+ ecs: {
171
+ version: "1.8"
172
+ },
173
+ message: m,
174
+ log: {
175
+ level: s.downcase,
176
+ logger: "Loggerstash",
177
+ origin: {
178
+ base_function: caller.base_label, # not in ECS
179
+ file: {
180
+ line: caller.lineno,
181
+ name: caller.absolute_path,
182
+ },
183
+ function: caller.label,
184
+ },
185
+ },
186
+ host: {
187
+ hostname: Socket.gethostname,
188
+ },
189
+ process: {
190
+ pid: $$,
191
+ thread: {
192
+ id: Thread.current.object_id,
193
+ },
194
+ },
195
+ }.tap do |ev|
196
+ ev[:process][:name] = p if p
197
+ ev[:process][:thread][:name] = Thread.current.name if Thread.current.name
198
+ end
199
+ end
200
+ end
201
+
202
+ # Identify the absolute path of the file that defines the Logger class.
203
+ #
204
+ def logger_filename
205
+ @logger_filename ||= Logger.instance_method(:format_message).source_location.first
206
+ end
186
207
  end
187
208
  end
data/loggerstash.gemspec CHANGED
@@ -1,15 +1,9 @@
1
- begin
2
- require 'git-version-bump'
3
- rescue LoadError
4
- nil
5
- end
1
+ # frozen_string_literal: true
6
2
 
7
3
  Gem::Specification.new do |s|
8
4
  s.name = "loggerstash"
9
5
 
10
- s.version = GVB.version rescue "0.0.0.1.NOGVB"
11
- s.date = GVB.date rescue Time.now.strftime("%Y-%m-%d")
12
-
6
+ s.version = "1.1.0"
13
7
  s.platform = Gem::Platform::RUBY
14
8
 
15
9
  s.summary = "Monkeypatch Logger to send log entries to logstash"
@@ -19,26 +13,24 @@ Gem::Specification.new do |s|
19
13
  however the message would have been handled otherwise.
20
14
  EOF
21
15
 
22
- s.authors = ["Matt Palmer"]
23
- s.email = ["matt.palmer@discourse.org"]
16
+ s.authors = ["Michael Brown"]
17
+ s.email = ["michael.brown@discourse.org"]
24
18
  s.homepage = "https://github.com/discourse/loggerstash"
25
19
 
26
20
  s.files = `git ls-files -z`.split("\0").reject { |f| f =~ /^(G|spec|Rakefile)/ }
27
21
 
28
- s.required_ruby_version = ">= 2.3.0"
22
+ s.required_ruby_version = ">= 2.5.0"
29
23
 
30
- s.add_runtime_dependency "logstash_writer", "~> 0.0"
24
+ s.add_runtime_dependency "logstash_writer", ">= 0.0.11"
31
25
 
32
26
  s.add_development_dependency 'bundler'
33
- s.add_development_dependency 'github-release'
34
- s.add_development_dependency 'git-version-bump'
35
27
  s.add_development_dependency 'guard-rspec'
36
28
  s.add_development_dependency 'guard-rubocop'
37
29
  s.add_development_dependency 'rack-test'
38
- s.add_development_dependency 'rake', "~> 12.0"
30
+ s.add_development_dependency 'rake', "~> 13.0"
39
31
  s.add_development_dependency 'redcarpet'
40
32
  s.add_development_dependency 'rspec'
41
- s.add_development_dependency 'rubocop'
33
+ s.add_development_dependency 'rubocop-discourse'
42
34
  s.add_development_dependency 'simplecov'
43
35
  s.add_development_dependency 'yard'
44
36
  end
metadata CHANGED
@@ -1,59 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggerstash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Matt Palmer
7
+ - Michael Brown
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-17 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash_writer
15
15
  requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.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.0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
16
  requirements:
38
17
  - - ">="
39
18
  - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: github-release
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
19
+ version: 0.0.11
20
+ type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - ">="
53
25
  - !ruby/object:Gem::Version
54
- version: '0'
26
+ version: 0.0.11
55
27
  - !ruby/object:Gem::Dependency
56
- name: git-version-bump
28
+ name: bundler
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
@@ -114,14 +86,14 @@ dependencies:
114
86
  requirements:
115
87
  - - "~>"
116
88
  - !ruby/object:Gem::Version
117
- version: '12.0'
89
+ version: '13.0'
118
90
  type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
93
  requirements:
122
94
  - - "~>"
123
95
  - !ruby/object:Gem::Version
124
- version: '12.0'
96
+ version: '13.0'
125
97
  - !ruby/object:Gem::Dependency
126
98
  name: redcarpet
127
99
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +123,7 @@ dependencies:
151
123
  - !ruby/object:Gem::Version
152
124
  version: '0'
153
125
  - !ruby/object:Gem::Dependency
154
- name: rubocop
126
+ name: rubocop-discourse
155
127
  requirement: !ruby/object:Gem::Requirement
156
128
  requirements:
157
129
  - - ">="
@@ -197,20 +169,20 @@ description: |
197
169
  it to send all logged entries to a Logstash server, in addition to
198
170
  however the message would have been handled otherwise.
199
171
  email:
200
- - matt.palmer@discourse.org
172
+ - michael.brown@discourse.org
201
173
  executables: []
202
174
  extensions: []
203
175
  extra_rdoc_files: []
204
176
  files:
177
+ - ".editorconfig"
178
+ - ".github/workflows/ci.yml"
205
179
  - ".gitignore"
206
180
  - ".rubocop.yml"
207
- - ".travis.yml"
208
181
  - ".yardopts"
209
182
  - CODE_OF_CONDUCT.md
210
183
  - CONTRIBUTING.md
211
184
  - LICENCE
212
185
  - README.md
213
- - lib/filtered_debug_logger.rb
214
186
  - lib/loggerstash.rb
215
187
  - loggerstash.gemspec
216
188
  homepage: https://github.com/discourse/loggerstash
@@ -224,15 +196,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
196
  requirements:
225
197
  - - ">="
226
198
  - !ruby/object:Gem::Version
227
- version: 2.3.0
199
+ version: 2.5.0
228
200
  required_rubygems_version: !ruby/object:Gem::Requirement
229
201
  requirements:
230
202
  - - ">="
231
203
  - !ruby/object:Gem::Version
232
204
  version: '0'
233
205
  requirements: []
234
- rubyforge_project:
235
- rubygems_version: 2.5.2.1
206
+ rubygems_version: 3.1.4
236
207
  signing_key:
237
208
  specification_version: 4
238
209
  summary: Monkeypatch Logger to send log entries to logstash
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
-
5
- rvm:
6
- - 2.5.1
7
- - 2.4.4
8
- - 2.3.7
9
-
10
- gemfile:
11
- - Gemfile
@@ -1,42 +0,0 @@
1
- require 'logger'
2
-
3
- # Filter debug-level log entries on progname
4
- #
5
- # Whilst well-thought-out debug logs are fantastic at showing you the
6
- # fine-level detail of your program's execution, they can sometimes be
7
- # "too much of a good thing". Excessively verbose debug logs can obscure
8
- # the important debug info, and turning on debug logging on a busy service
9
- # can quickly swamp all but the most overprovisioned of log aggregation
10
- # systems.
11
- #
12
- # Hence, there's this little module. Require it in your program, and then
13
- # set `logger.permitted_prognames = ['some', 'array']` on whatever logger
14
- # is likely to want some debug logging. Then, whenever debug logging is
15
- # enabled, only those calls to `logger.debug` which provide a progname exactly
16
- # matching an entry in the list you provided will actually get logged.
17
- #
18
- module FilteredDebugLogger
19
- # Set the list of prognames to log debug messages for.
20
- #
21
- # @param l [Array<String>] the (exact) prognames to log debug-level messages
22
- # for. If it's not in this list, it doesn't get emitted, even if debug
23
- # logging is enabled.
24
- #
25
- def permitted_prognames=(l)
26
- raise ArgumentError, "Must provide an array" unless l.is_a?(Array)
27
-
28
- @permitted_prognames = l
29
- end
30
-
31
- # Decorate Logger#add with our "reject by progname" logic.
32
- #
33
- def add(s, m = nil, p = nil)
34
- return if s == Logger::DEBUG && @permitted_prognames && !@permitted_prognames.include?(p)
35
-
36
- super
37
- end
38
-
39
- alias log add
40
- end
41
-
42
- Logger.prepend(FilteredDebugLogger)