Skip to content

Conversation

chojs23
Copy link

@chojs23 chojs23 commented Oct 21, 2025

Track ANSI color state across log lines so container output with color codes spanning multiple lines preserves formatting on all lines, not just the first.

This fix adds an ansiState field to the presenter struct to track active ANSI SGR (color/style) codes per container and restores them at the start of each line.
Only handles SGR codes (colors, bold, underline).

Fixes #12789

@chojs23 chojs23 requested a review from a team as a code owner October 21, 2025 00:59
@chojs23 chojs23 requested review from glours and ndeloof October 21, 2025 01:00
Adds ANSI state tracking to the presenter struct,
restoring color codes at the start of each line and properly
resetting them at line end.

Signed-off-by: neo <chojs990222@gmail.com>
@chojs23 chojs23 force-pushed the handle-ansi-color-logs branch from cd62dd8 to d94ede3 Compare October 21, 2025 04:54
@ndeloof
Copy link
Contributor

ndeloof commented Oct 21, 2025

I don't think this is a feature we should support in Compose: While some process may only rely on coloring, ANSI-enabled output is used by many tools with cursor-position ANSI sequence (typically to show computation progress, same as Compose does) which will break Compose logs formatting.

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.

[BUG] ANSI escape color formatting lost on multiple lines in logs

2 participants