Class: Moon::Test::Logger

Inherits:
Object show all
Defined in:
lib/moon/packages/test/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = nil) ⇒ Logger

Returns a new instance of Logger.


13
14
15
16
# File 'lib/moon/packages/test/logger.rb', line 13

def initialize(io = nil)
  @c = Colorizer.new
  @io = io || STDERR
end

Instance Attribute Details

#cObject (readonly)

Returns the value of attribute c


8
9
10
# File 'lib/moon/packages/test/logger.rb', line 8

def c
  @c
end

#io#puts, #write

Returns:


11
12
13
# File 'lib/moon/packages/test/logger.rb', line 11

def io
  @io
end

Instance Method Details

#error(str) ⇒ Object


42
43
44
# File 'lib/moon/packages/test/logger.rb', line 42

def error(str)
  puts prefixed_format('ERROR: ', str, :light_red)
end

#note(str) ⇒ Object


34
35
36
# File 'lib/moon/packages/test/logger.rb', line 34

def note(str)
  puts prefixed_format('NOTE: ', str, :light_green)
end

#prefixed_format(prefix, str, color = :default) ⇒ Object


30
31
32
# File 'lib/moon/packages/test/logger.rb', line 30

def prefixed_format(prefix, str, color = :default)
  @c.call(prefix, :light_green) + str
end

22
23
24
# File 'lib/moon/packages/test/logger.rb', line 22

def print(*args)
  write(*args)
end

#puts(*args) ⇒ Object


26
27
28
# File 'lib/moon/packages/test/logger.rb', line 26

def puts(*args)
  @io.puts(*args)
end

#warn(str) ⇒ Object


38
39
40
# File 'lib/moon/packages/test/logger.rb', line 38

def warn(str)
  puts prefixed_format('WARN: ', str, :light_yellow)
end

#write(*args) ⇒ Object


18
19
20
# File 'lib/moon/packages/test/logger.rb', line 18

def write(*args)
  @io.write(*args)
end