File tree Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Original file line number Diff line number Diff line change @@ -57,33 +57,29 @@ def reset_color():
57
57
return '\033 [0m'
58
58
59
59
60
- def diag (level , msg , * args ):
61
- # Format output message as:
62
- # <tool>: <level>: msg
63
- # With the `<level>:` part being colored accordingly.
64
- sys .stderr .write (tool_name + ': ' )
60
+ def with_bold_color (color , string ):
61
+ if not color_enabled :
62
+ return string
63
+ return output_color (color ) + bold () + string + reset_color ()
65
64
66
- if color_enabled :
67
- output = output_color (level_colors [level ]) + bold ()
68
- if output :
69
- sys .stderr .write (output )
70
65
71
- sys .stderr .write (level_prefixes [level ])
66
+ def with_bold (string ):
67
+ if not color_enabled :
68
+ return string
69
+ return bold () + string + reset_color ()
72
70
73
- if color_enabled :
74
- output = reset_color () + bold ()
75
- if output :
76
- sys .stderr .write (output )
77
71
72
+ def diag (level , msg , * args ):
73
+ # Format output message as:
74
+ # <tool>: <level>: msg
75
+ # With the `<level>:` part being colored accordingly, and the message itself in bold.
76
+ prefix = level_prefixes [level ]
77
+ color = level_colors [level ]
78
78
if args :
79
79
msg = msg % args
80
- sys .stderr .write (str (msg ))
81
- sys .stderr .write ('\n ' )
82
80
83
- if color_enabled :
84
- output = reset_color ()
85
- if output :
86
- sys .stderr .write (output )
81
+ full_msg = f'{ tool_name } : { with_bold_color (color , prefix )} { with_bold (msg )} \n '
82
+ sys .stderr .write (full_msg )
87
83
88
84
89
85
def error (msg , * args ):
You can’t perform that action at this time.
0 commit comments