Module: RailsSpotlight::LogInterceptor

Defined in:
lib/rails_spotlight/log_interceptor.rb

Constant Summary collapse

SEVERITY =
%w[debug info warn error fatal unknown].freeze
SEVERITY_MAP =
{ 0 => 'debug', 1 => 'info', 2 => 'warn', 3 => 'error', 4 => 'fatal', 5 => 'unknown' }.freeze

Instance Method Summary collapse

Instance Method Details

#add(severity, message = nil, progname = nil) ⇒ Object

rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_spotlight/log_interceptor.rb', line 10

def add(severity, message = nil, progname = nil) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
  severity ||= 5
  return true if @logdev.nil? || severity < level

  progname = @progname if progname.nil?

  if message.nil?
    if block_given?
      message = yield
    else
      message = progname
      progname = @progname
    end
  end
  return true if _skip_logging?(message)

  _rails_spotlight_log(SEVERITY_MAP[severity], message, progname, :broadcast)
  super(severity, message, progname) if defined?(super)
  true
end

#debug(message = nil, *args, &block) ⇒ Object



32
33
34
35
# File 'lib/rails_spotlight/log_interceptor.rb', line 32

def debug(message = nil, *args, &block)
  _rails_spotlight_log(:debug, message, nil, :event, &block)
  super
end

#error(message = nil, *args, &block) ⇒ Object



47
48
49
50
# File 'lib/rails_spotlight/log_interceptor.rb', line 47

def error(message = nil, *args, &block)
  _rails_spotlight_log(:error, message, nil, :event, &block)
  super
end

#fatal(message = nil, *args, &block) ⇒ Object



52
53
54
55
# File 'lib/rails_spotlight/log_interceptor.rb', line 52

def fatal(message = nil, *args, &block)
  _rails_spotlight_log(:fatal, message, nil, :event, &block)
  super
end

#info(message = nil, *args, &block) ⇒ Object



37
38
39
40
# File 'lib/rails_spotlight/log_interceptor.rb', line 37

def info(message = nil, *args, &block)
  _rails_spotlight_log(:info, message, nil, :event, &block)
  super
end

#unknown(message = nil, *args, &block) ⇒ Object



57
58
59
60
# File 'lib/rails_spotlight/log_interceptor.rb', line 57

def unknown(message = nil, *args, &block)
  _rails_spotlight_log(:unknown, message, nil, :event, &block)
  super
end

#warn(message = nil, *args, &block) ⇒ Object



42
43
44
45
# File 'lib/rails_spotlight/log_interceptor.rb', line 42

def warn(message = nil, *args, &block)
  _rails_spotlight_log(:warn, message, nil, :event, &block)
  super
end