2012-10-18 3 views

답변

5

bash 프롬프트에서 색상을 추가하려면 인쇄 할 수없는 이스케이프 시퀀스를 작성해야합니다.

ANSI Escape Sequences: Colours and Cursor Movement을 읽어 보시기 바랍니다.

간단한 예는 수 :

require 'logger' 
logobj = Logger.new('a_file') 
logobj.info "\033[31mThis text is red." 
logobj.info "\033[32mThis text is green." 


# And in your bash, you'll show colors by doing: 
cat a_file 

편집

당신은 또한 다음과 같이 작동 colored gem, 사용할 수

:

내가주고 내 대답을 업데이 트했습니다
logobj.info "Its log file.".red 
+0

절대적으로 :'colored' 보석은 모든 로깅 컨텍스트에 있어야합니다! :-) –

관련 문제