Class: RunLoop::Logging

Inherits:
Object
  • Object
show all
Defined in:
lib/run_loop/logging.rb

Class Method Summary collapse

Class Method Details

.debug_puts(msg) ⇒ Object



31
32
33
# File 'lib/run_loop/logging.rb', line 31

def self.debug_puts(msg)
  puts msg if RunLoop::Environment.debug?
end

.log_debug(logger, message) ⇒ Object



8
9
10
# File 'lib/run_loop/logging.rb', line 8

def self.log_debug(logger, message)
  log_level :debug, logger, message
end

.log_header(logger, message) ⇒ Object



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

def self.log_header(logger, message)
  msg = "\n\e[#{35}m### #{message} ###\e[0m"
  if logger.respond_to?(:debug)
    logger.debug(msg)
  else
    debug_puts(msg)
  end
end

.log_info(logger, message) ⇒ Object



4
5
6
# File 'lib/run_loop/logging.rb', line 4

def self.log_info(logger, message)
  log_level :info, logger, message
end

.log_level(level, logger, message) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/run_loop/logging.rb', line 21

def self.log_level(level, logger, message)
  level = level.to_sym
  msg = "#{Time.now} [RunLoop:#{level}]: #{message}"
  if logger.respond_to?(level)
    logger.send(level, msg)
  else
    debug_puts(msg)
  end
end