Class: Macinbox::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/macinbox/logger.rb

Constant Summary collapse

PREFIXES =
["", "  + ", "    - "]
@@depth =
0

Class Method Summary collapse

Class Method Details

.error(msg) ⇒ Object



21
22
23
# File 'lib/macinbox/logger.rb', line 21

def self.error(msg)
  STDERR.puts TTY::Color::RED + prefix + msg + TTY::Color::RESET
end

.info(msg) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/macinbox/logger.rb', line 13

def self.info(msg)
  STDERR.puts TTY::Color::GREEN + prefix + msg + TTY::Color::RESET
  if block_given?
    @@depth += 1
    yield
    @@depth -= 1
  end
end

.prefixObject



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

def self.prefix
  PREFIXES[@@depth]
end

.reset_depthObject



10
11
12
# File 'lib/macinbox/logger.rb', line 10

def self.reset_depth
  @@depth = 0
end