loggerstash 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f2945f9572e10047201fc9b3ac4422923e8b58b
4
- data.tar.gz: 7652bff72a6bb80fe20fcfd1d6ffe7c55679bc8f
3
+ metadata.gz: e7457877e4624e0e913b3f57a9dd064bce2476c2
4
+ data.tar.gz: 384ad7c464d4e7ca58b1625cb72925ddc926a437
5
5
  SHA512:
6
- metadata.gz: 3c2c0be50c3a3706dca83b4e7b26c549f920c41c88fb73d0e397c1b5aa5ff99d9d89057d15d5a2adff18b3f4043b835e8a4a4474c69dc34e78a712ff3b20114e
7
- data.tar.gz: 81d0b3da5b0ccabd57f6beaa74b43b993f33b11a23a1b2b9bb9aa3b96362043aca95626d3c0bf71ce0ad52021ce74fac3e0e1627a8bb95cca186f175098b3e6d
6
+ metadata.gz: c373e01de7e88ce5ab4674702661c09d7a248f00394c946a74a62dde4868526f3346932ddc87891147fa0a6c536b71ab8a50cf2fcf8647a62a7f99b53c61fdc6
7
+ data.tar.gz: 1c005e83c7991f52b41c71eed58be40121283d187eac39e7d7ba9da9744f6735097f578e52d5b533bbe6dac3dcc31465738b14767f08bdd359531ce9bc766abf
@@ -111,6 +111,8 @@ Layout/MultilineMethodCallIndentation:
111
111
 
112
112
  Layout/AlignHash:
113
113
  Enabled: true
114
+ EnforcedHashRocketStyle: table
115
+ EnforcedColonStyle: table
114
116
 
115
117
  Bundler/OrderedGems:
116
118
  Enabled: false
@@ -139,6 +139,8 @@ class Loggerstash
139
139
  #
140
140
  def default_formatter
141
141
  @default_formatter ||= ->(s, t, p, m) do
142
+ caller = caller_locations.find { |loc| ! [__FILE__, logger_filename].include? loc.absolute_path }
143
+
142
144
  {
143
145
  "@timestamp": t.utc.strftime("%FT%T.%NZ"),
144
146
  "@metadata": { event_type: "loggerstash" },
@@ -146,12 +148,25 @@ class Loggerstash
146
148
  severity_name: s.downcase,
147
149
  hostname: Socket.gethostname,
148
150
  pid: $$,
151
+ caller: {
152
+ absolute_path: caller.absolute_path,
153
+ base_label: caller.base_label,
154
+ label: caller.label,
155
+ lineno: caller.lineno,
156
+ path: caller.path,
157
+ },
149
158
  }.tap do |ev|
150
159
  ev[:progname] = p if p
151
160
  end
152
161
  end
153
162
  end
154
163
 
164
+ # Identify the absolute path of the file that defines the Logger class.
165
+ #
166
+ def logger_filename
167
+ @logger_filename ||= Logger.instance_method(:format_message).source_location.first
168
+ end
169
+
155
170
  # The methods needed to turn any Logger into a Loggerstash Logger.
156
171
  #
157
172
  module Mixin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggerstash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-17 00:00:00.000000000 Z
11
+ date: 2018-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash_writer
@@ -210,7 +210,6 @@ files:
210
210
  - CONTRIBUTING.md
211
211
  - LICENCE
212
212
  - README.md
213
- - lib/filtered_debug_logger.rb
214
213
  - lib/loggerstash.rb
215
214
  - loggerstash.gemspec
216
215
  homepage: https://github.com/discourse/loggerstash
@@ -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)
OSZAR »