smart_logger_wrapper 0.3.0 → 0.3.1

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
2
  SHA1:
3
- metadata.gz: 558223eabf09d913bbcb7ff302e8324a898df644
4
- data.tar.gz: 23d518a2d535c9fbd9a71ba4eb734d8402cff775
3
+ metadata.gz: f45d9e44bc4f77ee5b3f83e20fb5e2218c730eb5
4
+ data.tar.gz: 3cee85975631e80310d7bf41aa00af346cefae86
5
5
  SHA512:
6
- metadata.gz: 8a5035037cd1fcde6dcd95fb7c8802c479ef11ade20dc8ebd9f11eb8c4e9f3f278e107f25b0bf8638fe3864708dd47a6114e193eeb1221a07b50d4e09a2ea8b5
7
- data.tar.gz: e3c2fa794d687d95428e0c3a90a91a7d33a49a8dde282f42b1fd9a1448e40dc55aa09009e62cfce30be6ce15e591b67228ee30e15821f6344bfd991fc5ee26fc
6
+ metadata.gz: f6c9bd513546ab8151367defcb7a210deab757ad5c20d313b2ae3ba00a4134230457030c8c231dc5c216808c7ca53d7f017131c06ed9139b2f7ae7c93cbd94ae
7
+ data.tar.gz: 8fcd107646c2e6e2af92a78eccaba36287fee0177d6d90adbe1cb78ab734a28a6d34a801b84592df51c51753dc97603448996689b427e155454f45ff9f9c43d0
@@ -8,14 +8,15 @@ class SmartLoggerWrapper < Logger
8
8
 
9
9
  def get_backtrace(start, length = nil)
10
10
  # add 1 to `start` because this method dug the backtrace by 1
11
- backtrace = clean_backtrace(caller_locations(start + 1).map(&:to_s).lazy)
11
+ backtrace = clean_backtrace(caller_locations(start + 1).map(&:to_s))
12
12
  length == nil ? backtrace.to_a : backtrace.first(length)
13
13
  end
14
14
 
15
15
  def clean_backtrace(backtrace)
16
16
  (
17
17
  if defined?(::Rails) && ::Rails.respond_to?(:backtrace_cleaner)
18
- Rails.backtrace_cleaner.filter(backtrace)
18
+ head, *tail = backtrace
19
+ [head] + Rails.backtrace_cleaner.filter(tail)
19
20
  else
20
21
  backtrace
21
22
  end
@@ -1,5 +1,5 @@
1
1
  require 'logger'
2
2
 
3
3
  class SmartLoggerWrapper < Logger
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
@@ -15,6 +15,7 @@ class SmartLoggerWrapper < Logger
15
15
  fatal: FATAL,
16
16
  unknown: UNKNOWN
17
17
  }.freeze
18
+ DELEGETING_METHODS = %i(<< reopen close log add level debug? level= progname datetime_format= datetime_format formatter sev_threshold sev_threshold= info? warn? error? fatal? progname= formatter=)
18
19
 
19
20
  attr_reader :loggers, :options, :offset
20
21
 
@@ -27,18 +28,20 @@ class SmartLoggerWrapper < Logger
27
28
  end
28
29
 
29
30
  # For all methods with severity label, logger accepts multiple messages.
30
- # The return value is the first logger's.
31
+ # The return value is the first one of the first logger's.
31
32
  SEVERITY_MAPPING.each do |severity_name, severity|
32
33
  define_method(severity_name) do |*args, &block|
33
34
  format_messages(*args, &block).map do |message|
34
- add(severity, nil, message)
35
+ loggers.map do |logger|
36
+ logger.public_send(severity_name, message)
37
+ end.first
35
38
  end.first
36
39
  end
37
40
  end
38
41
 
39
42
  # Aside from #debug, #info, etc., all Logger instance methods are called for all the wrapped loggers.
40
43
  # The return value is the first logger's.
41
- (Logger.instance_methods(false) - SEVERITY_MAPPING.keys).each do |method_name|
44
+ DELEGETING_METHODS.each do |method_name|
42
45
  define_method(method_name) do |*args, &block|
43
46
  loggers.map do |logger|
44
47
  logger.public_send(method_name, *args, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_logger_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akihiro Katsura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-02 00:00:00.000000000 Z
11
+ date: 2018-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler