Class: BufferedLogger::Formatter

Inherits:
Object
  • Object
show all
Includes:
Term::ANSIColor
Defined in:
lib/buffered_logger/formatting.rb

Constant Summary collapse

FORMAT =
"%s"
COLOR =
true

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Formatter

Returns a new instance of Formatter.



51
52
53
54
# File 'lib/buffered_logger/formatting.rb', line 51

def initialize(params = {})
  @format = params[:format] || FORMAT
  @logger = params[:logger]
end

Instance Method Details

#%(message) ⇒ Object

formatting



74
75
76
77
# File 'lib/buffered_logger/formatting.rb', line 74

def %(message)
  formatted_message = @format % message.to_s
  parse_color(formatted_message)
end

#color?Boolean

color accessors

Returns:

  • (Boolean)


68
69
70
# File 'lib/buffered_logger/formatting.rb', line 68

def color?
  @logger ?  @logger.color? : COLOR
end

#format=(format) ⇒ Object



62
63
64
# File 'lib/buffered_logger/formatting.rb', line 62

def format=(format)
  @format = format.to_s 
end

#to_sObject

format accessors



58
59
60
# File 'lib/buffered_logger/formatting.rb', line 58

def to_s 
  @format 
end