davsclaus opened a new pull request, #29826: URL: https://github.com/apache/camel/pull/29826
## Summary An item of [CAMEL-26911](https://issues.apache.org/jira/browse/CAMEL-26911): **`camel log` was many times slower with colors (the default) when its output is a file or a pipe**, and gave the same output as without colors. With `--logging-color` (on by default), `camel log` prints each line, and the prefix of its integration, through jline's `AnsiConsole.out()`. When the output is not a terminal, that console takes the colors out of each piece of text it is given (`AnsiMode.Strip`), which is slow, and leaves the same text as `--logging-color=false`. 100,000 lines of a log, `camel log <name> --follow=false --tail=-1 > file`, with the unpacked launcher: | | `--logging-color=true` (default) | `--logging-color=false` | |---|---|---| | before | 19.8s | 0.6s | | after | 1.1s | 0.6s | The output with colors is byte-identical before and after (no ANSI codes in the file, as before). ### Fix - `CamelCommand.colorsStripped()`: the command prints to the console and the console strips the colors (the output is not a terminal). - `camel log` then prints the lines as with `--logging-color=false`: the ANSI codes of the log are taken out of each line once, without the console in between. - On a terminal the colors are printed as before (checked through a pseudo-terminal: every line has its ANSI codes), and so is the output for a CLI that runs the command in its own JVM (the shell, the TUI). ## Tests - `CamelLogActionTest.coloredLinesArePrintedWithoutColorsWhenTheConsoleStripsThem`: with a console that strips the colors, the lines have no ANSI codes, also the prefix of the integration. - camel-jbang-core passes locally. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
