lib/ProMotion/logger/logger.rb in ProMotion-2.0.1 vs lib/ProMotion/logger/logger.rb in ProMotion-2.1.0.beta1

- old
+ new

@@ -17,26 +17,31 @@ LEVELS = { off: [], error: [:error], warn: [:error, :warn], info: [:error, :warn, :info], + debug: [:error, :warn, :info, :debug], verbose: [:error, :warn, :info, :debug, :verbose], - debug: [:error, :warn, :info, :debug, :verbose] } def level - @level ||= :debug + @level ||= (RUBYMOTION_ENV == "release" ? :error : :debug) end + 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 + def levels LEVELS[self.level] || [] end # Usage: PM.logger.log("ERROR", "message here", :red) def log(label, message_text, color) - return if defined?(RUBYMOTION_ENV) && RUBYMOTION_ENV == "test" + # return if defined?(RUBYMOTION_ENV) && RUBYMOTION_ENV == "test" color = COLORS[color] || COLORS[:default] - puts color[0] + NAME + "[#{label}] #{message_text}" + color[1] + $stderr.puts color[0] + NAME + "[#{label}] #{message_text}" + color[1] nil end def error(message) log('ERROR', message, :red) if self.levels.include?(:error)