Module: BufferedLogger::Formatting

Included in:
BufferedLogger
Defined in:
lib/buffered_logger/formatting.rb

Constant Summary collapse

DEFAULT_LEVEL =
:default

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

magic format getters/setters



33
34
35
36
37
38
39
40
# File 'lib/buffered_logger/formatting.rb', line 33

def method_missing(method, *args, &block)
  case method.to_s
  when /^(#{BufferedLogger::SEVERITY_LEVELS.join('|')})_formatter(=)?$/
    $2 ? set_formatter($1.to_sym, args[0]) : formatter($1.to_sym)
  else
    super(method, *args, &block)
  end
end

Instance Method Details

#color?Boolean

Returns:

  • (Boolean)


12
# File 'lib/buffered_logger/formatting.rb', line 12

def color?; @color end

#disable_colorObject



14
# File 'lib/buffered_logger/formatting.rb', line 14

def disable_color; @color = false end

#enable_colorObject



15
# File 'lib/buffered_logger/formatting.rb', line 15

def enable_color; @color = true end

#initializeObject



6
7
8
9
10
# File 'lib/buffered_logger/formatting.rb', line 6

def initialize
  @formatter = BufferedLogger::ThreadHash.new { |h,k| h[k] = {} }
  @color = stdout?
  super()
end

#toggle_colorObject



13
# File 'lib/buffered_logger/formatting.rb', line 13

def toggle_color; @color = !@color end