Class: ActiveSupport::BufferedLogger

Inherits:
Object
  • Object
show all
Includes:
Severity
Defined in:
lib/color-debug.rb

Defined Under Namespace

Modules: Colors, Severity

Constant Summary

Constants included from Severity

Severity::COLORIZE

Instance Method Summary collapse

Instance Method Details

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



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/color-debug.rb', line 19

def add(severity, message = nil, progname = nil, color = nil, &block)
  return if @level > severity
  message = (message || (block && block.call) || progname).to_s
  color ||= Colors::MAGENTA
  message = "#{color}#{message}#{Colors::EC}\n" if severity == 10
  # If a newline is necessary then create a new message ending with a newline.
  # Ensures that the original message is not mutated.
  message = "#{message}\n" unless message[-1] == ?\n
  buffer << message
  auto_flush
  message
end