Class: Toolshed::Logger

Inherits:
Object
  • Object
show all
Includes:
Singleton, Term::ANSIColor
Defined in:
lib/toolshed/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggersObject

Returns the value of attribute loggers.



9
10
11
# File 'lib/toolshed/logger.rb', line 9

def loggers
  @loggers
end

Class Method Details

.create(options = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/toolshed/logger.rb', line 11

def self.create(options = {})
  instance.loggers = []
  log_sources = options[:log_sources] || [STDOUT]
  log_sources.each do |log_source|
    instance.loggers << Logger.new(log_source)
  end
end

Instance Method Details

#add_log_source(source) ⇒ Object



19
20
21
# File 'lib/toolshed/logger.rb', line 19

def add_log_source(source)
  loggers << Logger.new(source)
end

#debug(message) ⇒ Object



23
24
25
26
27
# File 'lib/toolshed/logger.rb', line 23

def debug(message)
  loggers.each do |logger|
    logger.debug(message)
  end
end

#fatal(message) ⇒ Object



29
30
31
32
33
# File 'lib/toolshed/logger.rb', line 29

def fatal(message)
  loggers.each do |logger|
    logger.info(red(message))
  end
end

#info(message) ⇒ Object



35
36
37
38
39
# File 'lib/toolshed/logger.rb', line 35

def info(message)
  loggers.each do |logger|
    logger.info(green(message))
  end
end

#warn(message) ⇒ Object



41
42
43
44
45
# File 'lib/toolshed/logger.rb', line 41

def warn(message)
  loggers.each do |logger|
    logger.warn(yellow(message))
  end
end