居然没有搜到,催悲的使用 raise 中。。。
把默认的 logger 改成 Logger.new(STDOUT)
,比如
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveResource::Base.logger = Logger.new(STDOUT)
ActionController::Base.logger = Logger.new(STDOUT)
多谢各位。
#1 楼 @vkill 看了下 pry,好像很复杂,收了慢慢看。
#2 楼 @zhangyuan #3 楼 @jonny #4 楼 @lb563 logger 果然很好用
#5 楼 @jinleileiking puts 果然也行,比 logger 还简单
再给你的输出加点颜色吧
# colorize for console output
class String
def colorize(color, options = {})
background = options[:background] || options[:bg] || false
style = options[:style]
offsets = ["gray","red", "green", "yellow", "blue", "magenta", "cyan","white"]
styles = ["normal","bold","dark","italic","underline","xx","xx","underline","xx","strikethrough"]
start = background ? 40 : 30
color_code = start + (offsets.index(color) || 8)
style_code = styles.index(style) || 0
"\e[#{style_code};#{color_code}m#{self}\e[0m"
end
end