Module: Ghaki::Logger::Liner

Included in:
Base
Defined in:
lib/ghaki/logger/liner.rb

Overview

Logging helpers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#box_charObject

Character used to make line separators in the logs.



7
8
9
# File 'lib/ghaki/logger/liner.rb', line 7

def box_char
  @box_char
end

#box_sizeObject

Character used to make line separators in the logs.



7
8
9
# File 'lib/ghaki/logger/liner.rb', line 7

def box_size
  @box_size
end

Instance Method Details

#box(msgs, box_char = @box_char, box_size = @box_size) ⇒ Object

Creates a log comment box around an array of strings.

box_char

Character used to make line separators in the logs.

box_size

Line length used for separators in the logs.



31
32
33
34
35
36
37
38
39
# File 'lib/ghaki/logger/liner.rb', line 31

def box msgs, box_char=@box_char, box_size=@box_size
  self.liner box_char, box_size
  [msgs].flatten.each do |text|
    text.each_line do |line|
      self.<< '# ' + box_char + ' ' + line.chomp + "\n"
    end
  end
  self.liner box_char, box_size
end

#fatal_dump(why) ⇒ Object

Dump exception to logger. Includes backtrace if debugging is set.



20
21
22
23
24
25
# File 'lib/ghaki/logger/liner.rb', line 20

def fatal_dump why
  self.fatal why.class.to_s + ' ' + why.to_s
  self.liner '!'
  self.puts why.backtrace if self.debug?
  self.liner '!'
end

#liner(box_char = @box_char, box_size = @box_size) ⇒ Object

Writes a log comment line.

box_char

Character used to make line separators in the logs.

box_size

Line length used for separators in the logs.



14
15
16
# File 'lib/ghaki/logger/liner.rb', line 14

def liner box_char=@box_char, box_size=@box_size
  self.puts( box_char * box_size ) if self.debug?
end

#puts(msgs) ⇒ Object

Write array of strings to logger, putting log comment characters in front of the lines.



43
44
45
46
47
48
49
# File 'lib/ghaki/logger/liner.rb', line 43

def puts msgs
  [msgs].flatten.each do |text|
    text.each_line do |line|
      self.<< '# ' + line.chomp + "\n"
    end
  end
end