Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Pull Request

Description
ANSI escape codes were appearing as plaintext in non-interactive terminals (CI pipelines, piped/redirected output), cluttering logs with sequences like \033[92m.

Modified color_logger.py to check sys.stdout.isatty() before applying color codes:

  • Interactive terminals (TTY): Apply color codes normally
  • Non-interactive (CI/pipes/files): Omit escape codes entirely

Related Issue
Fixes #[issue_number]

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional Context
The fix is minimal - one import and one conditional check:

# Before
colored_message = f"{color}{message}{reset}"

# After
colored_message = f"{color}{message}{reset}" if sys.stdout.isatty() else f"{message}"

Verified with:

# Interactive: shows colors
python3 script.py

# CI/piped: no escape codes
python3 script.py | cat
python3 script.py > log.txt
Original prompt

This section details on the original issue you should resolve

<issue_title>Escape code characters in CI pipelines</issue_title>
<issue_description>

def log(self, level, message):
reset = "\033[0m"
color = self.LEVEL_COLORS.get(level, "")
level_str = self.LEVEL_STRING.get(level, ' ')
colored_message = f"{color}{message}{reset}"
timestamp = datetime.datetime.now().strftime("%H:%M:%S")
self.logger.log(level, f"[{timestamp}] {level_str} : {colored_message if self.color_enabled else message}")

In this block of code, the log message is wrapped around color specific escape codes. Non interactive terminals don't understand these escape codes and hence they are printed in plaintext.
We can check for existence of an interactive terminal and proceed with our logging accordingly

 def log(self, level, message): 
     ....
     colored_message = f"{message}" if sys.stdout.isatty() else f"{color}{message}{reset}"
     ....
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix escape code characters in CI pipelines Fix escape code characters in CI pipelines Nov 13, 2025
Copilot finished work on behalf of simonbeaudoin0935 November 13, 2025 18:39
@simonbeaudoin0935 simonbeaudoin0935 marked this pull request as ready for review November 14, 2025 18:31
@simonbeaudoin0935 simonbeaudoin0935 force-pushed the copilot/escape-code-characters-ci-pipelines branch from ee65a33 to 4854ec3 Compare November 20, 2025 22:40
@simonbeaudoin0935 simonbeaudoin0935 merged commit b235d54 into main Nov 20, 2025
9 checks passed
@simonbeaudoin0935 simonbeaudoin0935 deleted the copilot/escape-code-characters-ci-pipelines branch November 20, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Escape code characters in CI pipelines

3 participants