Skip to content

Commit 6f12eed

Browse files
committed
feat(debugger): lighter color for timestamps and respect the `--no-color' command line switch to disable colored output
1 parent d1c72c2 commit 6f12eed

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/debugger/src/robotcode/debugger/debugger.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def __init__(self) -> None:
298298
self.output_messages: bool = False
299299
self.output_log: bool = False
300300
self.output_timestamps: bool = False
301+
self.colored_output: bool = True
301302
self.group_output: bool = False
302303
self.hit_counts: Dict[HitCountEntry, int] = {}
303304
self.last_fail_message: Optional[str] = None
@@ -1195,9 +1196,16 @@ def _send_log_event(self, timestamp: str, level: str, msg: str, category: Union[
11951196
)
11961197

11971198
def _build_output(self, level: str, msg: str, timestamp: str) -> str:
1199+
if self.colored_output:
1200+
return (
1201+
(f"\u001b[38;5;243m{timestamp.split(' ', 1)[1]}\u001b[0m " if self.output_timestamps else "")
1202+
+ (f"[ {self.MESSAGE_COLORS.get(level, '')}{level}\u001b[0m ] " if level != "INFO" else "")
1203+
+ f"{msg}\n"
1204+
)
1205+
11981206
return (
1199-
(f"\u001b[38;5;237m{timestamp.split(' ', 1)[1]}\u001b[0m " if self.output_timestamps else "")
1200-
+ (f"[ {self.MESSAGE_COLORS.get(level, '')}{level}\u001b[0m ] " if level != "INFO" else "")
1207+
(f"{timestamp.split(' ', 1)[1]} " if self.output_timestamps else "")
1208+
+ (f"[ {level} ] " if level != "INFO" else "")
12011209
+ f"{msg}\n"
12021210
)
12031211

packages/debugger/src/robotcode/debugger/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ async def run_debugger(
197197
Debugger.instance().output_log = output_log
198198
Debugger.instance().group_output = group_output
199199
Debugger.instance().output_timestamps = output_timestamps
200+
Debugger.instance().colored_output = app.colored
200201
Debugger.instance().debug = debug
201202
Debugger.instance().set_main_thread(threading.current_thread())
202203
Debugger.instance().server_loop = server.loop

0 commit comments

Comments
 (0)