Rails4 WEBrick Color
                                            
                                                
                                                
                                                
                                                
                                                
                                                 6321 단어  Rails4
                    
config/initializers/log_formatter.rb
class ActiveSupport::Logger::SimpleFormatter
  # from activesupport/lib/active_support/core_ext/logger.rb
  def call(severity, time, progname, msg)
    "#{severity_msg_color(severity, msg)} \n"
  end
private
  def severity_msg_color(severity, msg)
    case severity
    when "DEBUG"
      "\033[0;32;40m[DEBUG]\033[0m \033[32m#{String === msg ? msg : msg.inspect}\033[0m"
    when "INFO"
      "\033[1;30;40m[INFO]\033[0m \033[30m#{String === msg ? msg : msg.inspect}\033[0m"
    when "WARN"
      "\033[1;33;40m[WARNING]\033[0m \033[33m#{String === msg ? msg : msg.inspect}\033[0m"
    when "ERROR"
      "\033[0;31;40m[ERROR]\033[0m \033[0;31m#{String === msg ? msg : msg.inspect}\033[0m"
    when "FATAL"
      "\033[7;31;40m[FATAL]\033[0m \033[31m#{String === msg ? msg : msg.inspect}\033[0m"
    else
      "[#{severity}]" # none
    end
  end
end
ANSI Color code (16colors)
# Text attributes
#  0  All attributes off
#  1  Bold on
#  4  Underscore (on monochrome display adapter only)
#  5  Blink on
#  7  Reverse video on
#  8  Concealed on
# Foreground colors
#  0;30   Black          1;30   Dark Gray
#  0;34   Blue           1;34   Light Blue
#  0;32   Green          1;32   Light Green
#  0;36   Cyan           1;36   Light Cyan
#  0;31   Red            1;31   Light Red
#  0;35   Purple         1;35   Light Purple
#  0;33   Brown          1;33   Yellow
#  0;37   Light Gray     1;37   White
# Background colors
#  40   Black
#  41   Red
#  42   Green
#  43   Yellow
#  44   Blue
#  45   Magenta
#  46   Cyan
#  47   White
Log(iTerm2)

참고 링크
Reference
이 문제에 관하여(Rails4 WEBrick Color), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/saiwaki/items/e4908721ac6f95897c70텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)