File tree Expand file tree Collapse file tree 3 files changed +21
-15
lines changed Expand file tree Collapse file tree 3 files changed +21
-15
lines changed Original file line number Diff line number Diff line change 110.1.7
22
3+ * Only colorize output when logging to a TTY
34* Fix crashing --list-templates flag
45
560.1.6
Original file line number Diff line number Diff line change @@ -5,32 +5,44 @@ module Overcommit
55 class Logger
66 include Singleton
77
8+ attr_accessor :output
9+
810 def partial ( *args )
9- print *args
11+ out . print *args
1012 end
1113
1214 def log ( *args )
13- puts *args
15+ out . puts *args
1416 end
1517
1618 def bold ( str )
17- log " \033 [1;37m #{ str } \033 [0m"
19+ color ( '1;37' , str )
1820 end
1921
2022 def error ( str )
21- log " \033 [31m #{ str } \033 [0m"
23+ color ( 31 , str )
2224 end
2325
2426 def success ( str )
25- log " \033 [32m #{ str } \033 [0m"
27+ color ( 32 , str )
2628 end
2729
2830 def warning ( str )
29- log " \033 [33m #{ str } \033 [0m"
31+ color ( 33 , str )
3032 end
3133
3234 def notice ( str )
33- log "\033 [1;33m#{ str } \033 [0m"
35+ color ( '1;33' , str )
36+ end
37+
38+ def out
39+ self . output ||= $stdout
40+ end
41+
42+ private
43+
44+ def color ( code , str )
45+ log ( out . isatty ? "\033 [#{ code } m#{ str } \033 [0m" : str )
3446 end
3547 end
3648end
Original file line number Diff line number Diff line change 88
99def exit ( *args ) ; end
1010
11- # Silence output to STDOUT
12- class Overcommit ::Logger
13- def log ( *args )
14- end
15-
16- def partial ( *args )
17- end
18- end
11+ Overcommit ::Logger . instance . output = StringIO . new
You can’t perform that action at this time.
0 commit comments