Module: Log::Format

Defined in:
lib/log/format.rb,
lib/log/format/color.rb

Defined Under Namespace

Modules: Color, Defaults

Class Method Summary collapse

Class Method Details

.header(time, subject, level, device) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/log/format.rb', line 21

def self.header(time, subject, level, device)
  header = "[#{time}] #{subject}"
  unless level.nil?
    header << " #{level.to_s.upcase}"
  end
  header << ':'
  Color.header(header, device)
end

.line(message, time, subject, level, device, &message_formatter) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/log/format.rb', line 3

def self.line(message, time, subject, level, device, &message_formatter)
  header = nil
  if Defaults.header == :on
    header = "#{header(time, subject, level, device)} "
  end

  "#{header}#{message(message, device, &message_formatter)}"
end

.message(message, device, &message_formatter) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/log/format.rb', line 12

def self.message(message, device, &message_formatter)
  return message unless block_given?
  if Log::Defaults.formatters == :on
    return message_formatter.(message, device)
  else
    return message
  end
end