How can I colorize log output in rails 3 console

How can I colorize and possibly bold output from Rails.logger in my rails3 application?

+3
source share
2 answers

Be kind to other programmers; do not insert escape sequences directly into your lines. Perhaps use a library like Rainbow or Term-ANSIColor ? For example, Term-ANSIColor:

require 'term/ansicolor'
include Term::ANSIColor

Rails.logger.add 1, "#{red(ATCHUNG!)}: pay attention to me!"
+7
source

Source: https://habr.com/ru/post/1758308/


All Articles