class ProMotion::Logger

Constants

COLORS
LEVELS
NAME

Attributes

level[RW]

Public Instance Methods

debug(message) click to toggle source
# File lib/ProMotion/logger/logger.rb, line 58
def debug(message)
  log('DEBUG', message, :purple) if self.levels.include?(:debug)
end
deprecated(message) click to toggle source
# File lib/ProMotion/logger/logger.rb, line 50
def deprecated(message)
  log('DEPRECATED', message, :yellow) if self.levels.include?(:warn)
end
error(message) click to toggle source
# File lib/ProMotion/logger/logger.rb, line 46
def error(message)
  log('ERROR', message, :red) if self.levels.include?(:error)
end
info(message) click to toggle source
# File lib/ProMotion/logger/logger.rb, line 62
def info(message)
  log('INFO', message, :green) if self.levels.include?(:info)
end
level=(new_level) click to toggle source
# File lib/ProMotion/logger/logger.rb, line 30
def level=(new_level)
  log('LOG LEVEL', 'Setting PM.logger to :verbose will make everything REALLY SLOW!', :purple) if new_level == :verbose
  @level = new_level
end
levels() click to toggle source
# File lib/ProMotion/logger/logger.rb, line 35
def levels
  LEVELS[self.level] || []
end
log(label, message_text, color) click to toggle source

Usage: PM.logger.log(“ERROR”, “message here”, :red)

# File lib/ProMotion/logger/logger.rb, line 40
def log(label, message_text, color)
  show_deprecation_warning

  mp "#{NAME}[#{label}] #{message_text}", force_color: color
end
show_deprecation_warning() click to toggle source
# File lib/ProMotion/logger/logger.rb, line 66
def show_deprecation_warning
  mp "PM.logger.log has been deprecated. Please update to motion_print: https://github.com/OTGApps/motion_print", force_color: :yellow
end
warn(message) click to toggle source
# File lib/ProMotion/logger/logger.rb, line 54
def warn(message)
  log('WARN', message, :yellow) if self.levels.include?(:warn)
end