loggerstash 0.0.5 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +7 -0
- data/.github/workflows/ci.yml +47 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +6 -115
- data/CONTRIBUTING.md +1 -1
- data/README.md +1 -1
- data/lib/loggerstash.rb +98 -76
- data/loggerstash.gemspec +7 -14
- metadata +24 -39
- data/.travis.yml +0 -11
- data/lib/filtered_debug_logger.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4e961a1a3a243caad2487af5ef9d49ebe675d51cb85c54a615f40785ab8ad6c
|
4
|
+
data.tar.gz: befa0f4bc820cfb8340ac034796f782c72d62205a504e4f41fb7fabdab93f2c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f67b43b36d38f959b3ebe58fc60cee20ce077813458a8fffd720216e3af123c0df9d598c4aab222a44227272a0a2c43636b7efcd703c2286b2146b4b87e90992
|
7
|
+
data.tar.gz: 5286e5307c1d7c552e08b6301e9d0ef98abd0fac340592bf1b221f7c8de73535d0b54628487bbff005ecd27cdd1501eecc15d72d5396384d3a402a8a33ff34db
|
data/.editorconfig
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
name: Loggerstash Tests
|
3
|
+
|
4
|
+
"on":
|
5
|
+
pull_request:
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- master
|
9
|
+
tags:
|
10
|
+
- v*
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
name: Ruby ${{ matrix.ruby }}
|
16
|
+
strategy:
|
17
|
+
matrix:
|
18
|
+
ruby: ["2.7", "2.6", "2.5"]
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- uses: actions/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
- name: Bundler cache
|
25
|
+
uses: actions/cache@v2
|
26
|
+
with:
|
27
|
+
path: vendor/bundle
|
28
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
29
|
+
restore-keys: |
|
30
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-
|
31
|
+
- name: Setup gems
|
32
|
+
run: |
|
33
|
+
bundle config path vendor/bundle
|
34
|
+
bundle install --jobs 4
|
35
|
+
- name: Tests
|
36
|
+
run: bundle exec rake
|
37
|
+
|
38
|
+
publish:
|
39
|
+
if: contains(github.ref, 'refs/tags/v')
|
40
|
+
needs: build
|
41
|
+
runs-on: ubuntu-latest
|
42
|
+
steps:
|
43
|
+
- uses: actions/checkout@v2
|
44
|
+
- name: Release Gem
|
45
|
+
uses: discourse/publish-rubygems-action@main
|
46
|
+
env:
|
47
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,116 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
-
|
6
|
-
|
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:
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-discourse: default.yml
|
3
|
+
inherit_mode:
|
4
|
+
merge:
|
5
|
+
- Exclude
|
6
|
+
Layout/HashAlignment:
|
116
7
|
Enabled: false
|
data/CONTRIBUTING.md
CHANGED
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,36 +16,35 @@ 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
|
#
|
42
|
-
|
43
|
-
|
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
|
+
def initialize(logstash_server:, metrics_registry: nil, formatter: nil, logstash_writer: nil, logger: nil)
|
43
|
+
@logstash_server = logstash_server
|
44
44
|
@metrics_registry = metrics_registry
|
45
|
-
@formatter
|
46
|
-
@logstash_writer
|
45
|
+
@formatter = formatter
|
46
|
+
@logstash_writer = logstash_writer
|
47
|
+
@logger = logger
|
47
48
|
|
48
49
|
@op_mutex = Mutex.new
|
49
50
|
end
|
@@ -60,20 +61,21 @@ class Loggerstash
|
|
60
61
|
# benefit from the attachment; that's up to you to ensure.
|
61
62
|
#
|
62
63
|
def attach(obj)
|
64
|
+
run_writer
|
65
|
+
|
63
66
|
@op_mutex.synchronize do
|
64
|
-
obj.instance_variable_set(:@
|
67
|
+
obj.instance_variable_set(:@logstash_writer, @logstash_writer)
|
68
|
+
obj.instance_variable_set(:@loggerstash_formatter, @formatter)
|
65
69
|
|
66
70
|
if obj.is_a?(Module)
|
67
71
|
obj.prepend(Mixin)
|
68
72
|
else
|
69
73
|
obj.singleton_class.prepend(Mixin)
|
70
74
|
end
|
71
|
-
|
72
|
-
run_writer
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
76
|
-
%i{logstash_server metrics_registry}.each do |sym|
|
78
|
+
%i{formatter logger logstash_server metrics_registry}.each do |sym|
|
77
79
|
define_method(:"#{sym}=") do |v|
|
78
80
|
@op_mutex.synchronize do
|
79
81
|
if @logstash_writer
|
@@ -85,65 +87,25 @@ class Loggerstash
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
88
|
-
# Send a logger message to logstash.
|
89
|
-
#
|
90
|
-
# @private
|
91
|
-
#
|
92
|
-
def log_message(s, t, p, m)
|
93
|
-
@op_mutex.synchronize do
|
94
|
-
if @logstash_writer.nil?
|
95
|
-
#:nocov:
|
96
|
-
run_writer
|
97
|
-
#:nocov:
|
98
|
-
end
|
99
|
-
|
100
|
-
@logstash_writer.send_event((@formatter || default_formatter).call(s, t, p, m))
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
90
|
private
|
105
91
|
|
106
92
|
# Do the needful to get the writer going.
|
107
93
|
#
|
108
|
-
# This will error out unless the @op_mutex is held at the time the
|
109
|
-
# method is called; we can't acquire it ourselves because some calls
|
110
|
-
# to run_writer already need to hold the mutex.
|
111
|
-
#
|
112
94
|
def run_writer
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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!
|
125
108
|
end
|
126
|
-
|
127
|
-
@logstash_writer = LogstashWriter.new(**opts)
|
128
|
-
@logstash_writer.run
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# Mangle the standard sev/time/prog/msg set into a minimal logstash
|
134
|
-
# event.
|
135
|
-
#
|
136
|
-
def default_formatter
|
137
|
-
@default_formatter ||= ->(s, t, p, m) do
|
138
|
-
{
|
139
|
-
"@timestamp": t.utc.strftime("%FT%T.%NZ"),
|
140
|
-
"@metadata": { event_type: "loggerstash" },
|
141
|
-
message: m,
|
142
|
-
severity_name: s.downcase,
|
143
|
-
hostname: Socket.gethostname,
|
144
|
-
pid: $$,
|
145
|
-
}.tap do |ev|
|
146
|
-
ev[:progname] = p if p
|
147
109
|
end
|
148
110
|
end
|
149
111
|
end
|
@@ -151,26 +113,41 @@ class Loggerstash
|
|
151
113
|
# The methods needed to turn any Logger into a Loggerstash Logger.
|
152
114
|
#
|
153
115
|
module Mixin
|
116
|
+
attr_writer :logstash_writer, :loggerstash_formatter
|
117
|
+
|
154
118
|
private
|
155
119
|
|
156
120
|
# Hooking into this specific method may seem... unorthodox, but
|
157
121
|
# it seemingly has an extremely stable interface and is the most
|
158
122
|
# appropriate place to inject ourselves.
|
123
|
+
#
|
159
124
|
def format_message(s, t, p, m)
|
160
|
-
|
125
|
+
loggerstash_log_message(s, t, p, m)
|
161
126
|
|
162
127
|
super
|
163
128
|
end
|
164
129
|
|
165
|
-
#
|
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.
|
166
143
|
#
|
167
144
|
# We're kinda reimplementing Ruby's method lookup logic here, but there's
|
168
145
|
# no other way to store our object *somewhere* in the object + class
|
169
146
|
# hierarchy and still be able to get at it from a module (class variables
|
170
|
-
# don't like being accessed from modules).
|
171
|
-
#
|
172
|
-
def
|
173
|
-
|
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|
|
174
151
|
if ls.nil?
|
175
152
|
#:nocov:
|
176
153
|
raise RuntimeError,
|
@@ -179,5 +156,50 @@ class Loggerstash
|
|
179
156
|
end
|
180
157
|
end
|
181
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
|
+
message: m,
|
171
|
+
log: {
|
172
|
+
level: s.downcase,
|
173
|
+
logger: "Loggerstash",
|
174
|
+
origin: {
|
175
|
+
base_function: caller.base_label, # not in ECS
|
176
|
+
file: {
|
177
|
+
line: caller.lineno,
|
178
|
+
name: caller.absolute_path,
|
179
|
+
},
|
180
|
+
function: caller.label,
|
181
|
+
},
|
182
|
+
},
|
183
|
+
host: {
|
184
|
+
hostname: Socket.gethostname,
|
185
|
+
},
|
186
|
+
process: {
|
187
|
+
pid: $$,
|
188
|
+
thread: {
|
189
|
+
id: Thread.current.object_id,
|
190
|
+
},
|
191
|
+
},
|
192
|
+
}.tap do |ev|
|
193
|
+
ev[:process][:name] = p if p
|
194
|
+
ev[:process][:thread][:name] = Thread.current.name if Thread.current.name
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# Identify the absolute path of the file that defines the Logger class.
|
200
|
+
#
|
201
|
+
def logger_filename
|
202
|
+
@logger_filename ||= Logger.instance_method(:format_message).source_location.first
|
203
|
+
end
|
182
204
|
end
|
183
205
|
end
|
data/loggerstash.gemspec
CHANGED
@@ -1,15 +1,9 @@
|
|
1
|
-
|
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 =
|
11
|
-
s.date = GVB.date rescue Time.now.strftime("%Y-%m-%d")
|
12
|
-
|
6
|
+
s.version = "1.0.1"
|
13
7
|
s.platform = Gem::Platform::RUBY
|
14
8
|
|
15
9
|
s.summary = "Monkeypatch Logger to send log entries to logstash"
|
@@ -19,19 +13,17 @@ Gem::Specification.new do |s|
|
|
19
13
|
however the message would have been handled otherwise.
|
20
14
|
EOF
|
21
15
|
|
22
|
-
s.authors = ["
|
23
|
-
s.email = ["
|
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.
|
22
|
+
s.required_ruby_version = ">= 2.4.0"
|
29
23
|
|
30
|
-
s.add_runtime_dependency "logstash_writer", "
|
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'
|
@@ -39,6 +31,7 @@ Gem::Specification.new do |s|
|
|
39
31
|
s.add_development_dependency 'redcarpet'
|
40
32
|
s.add_development_dependency 'rspec'
|
41
33
|
s.add_development_dependency 'rubocop'
|
34
|
+
s.add_development_dependency 'rubocop-discourse'
|
42
35
|
s.add_development_dependency 'simplecov'
|
43
36
|
s.add_development_dependency 'yard'
|
44
37
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loggerstash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Michael Brown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-25 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
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.0.11
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.0.11
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: guard-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: guard-rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rack-test
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,21 +81,21 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
89
|
+
version: '12.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
96
|
+
version: '12.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: redcarpet
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,21 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '12.0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '12.0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: redcarpet
|
112
|
+
name: rspec
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - ">="
|
@@ -137,7 +123,7 @@ dependencies:
|
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
126
|
+
name: rubocop
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - ">="
|
@@ -151,7 +137,7 @@ dependencies:
|
|
151
137
|
- !ruby/object:Gem::Version
|
152
138
|
version: '0'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
|
-
name: rubocop
|
140
|
+
name: rubocop-discourse
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
143
|
- - ">="
|
@@ -197,20 +183,20 @@ description: |
|
|
197
183
|
it to send all logged entries to a Logstash server, in addition to
|
198
184
|
however the message would have been handled otherwise.
|
199
185
|
email:
|
200
|
-
-
|
186
|
+
- michael.brown@discourse.org
|
201
187
|
executables: []
|
202
188
|
extensions: []
|
203
189
|
extra_rdoc_files: []
|
204
190
|
files:
|
191
|
+
- ".editorconfig"
|
192
|
+
- ".github/workflows/ci.yml"
|
205
193
|
- ".gitignore"
|
206
194
|
- ".rubocop.yml"
|
207
|
-
- ".travis.yml"
|
208
195
|
- ".yardopts"
|
209
196
|
- CODE_OF_CONDUCT.md
|
210
197
|
- CONTRIBUTING.md
|
211
198
|
- LICENCE
|
212
199
|
- README.md
|
213
|
-
- lib/filtered_debug_logger.rb
|
214
200
|
- lib/loggerstash.rb
|
215
201
|
- loggerstash.gemspec
|
216
202
|
homepage: https://github.com/discourse/loggerstash
|
@@ -224,15 +210,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
210
|
requirements:
|
225
211
|
- - ">="
|
226
212
|
- !ruby/object:Gem::Version
|
227
|
-
version: 2.
|
213
|
+
version: 2.4.0
|
228
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
215
|
requirements:
|
230
216
|
- - ">="
|
231
217
|
- !ruby/object:Gem::Version
|
232
218
|
version: '0'
|
233
219
|
requirements: []
|
234
|
-
|
235
|
-
rubygems_version: 2.7.7
|
220
|
+
rubygems_version: 3.0.3
|
236
221
|
signing_key:
|
237
222
|
specification_version: 4
|
238
223
|
summary: Monkeypatch Logger to send log entries to logstash
|
data/.travis.yml
DELETED
@@ -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)
|