davsclaus opened a new pull request, #29827: URL: https://github.com/apache/camel/pull/29827
## Summary Two items of [CAMEL-26911](https://issues.apache.org/jira/browse/CAMEL-26911) in `camel log`: **the lines of a stack trace were moved away from their log record with several integrations, and the logs were not closed.** ### 1. Stack traces with several integrations With two or more integrations, `camel log` merges their logs by the timestamp at the start of each line. A line without a timestamp, such as a line of a stack trace, compared as earlier than every line with one, so all of them were sorted to the top of the output, away from the `ERROR` record they belong to. The comparator also parsed the timestamps of both lines on each comparison. #### Fix The lines of each log are grouped into records: a line with a timestamp, and the lines after it without one. The records are sorted by their timestamp, once each, with a stable sort, so the records of a log at the same time stay in order, and a stack trace stays right after its record. Lines without a timestamp at the start of a log (before its first record) come first, as before. One integration is printed as it is, as before. ### 2. The logs were not closed - `camel log --follow` did not close the log of an integration that stopped: one open file for each integration that stopped during a long follow. - Without `--follow`, the logs it read were not closed: one open file per log on each `camel log` in the JVM of the shell or the TUI, which run it in their JVM. The log of an integration that stopped is closed when it is dropped, and all the logs when the command ends. ## Tests - `CamelLogActionTest.aStackTraceStaysWithItsRecordInTheLogsOfSeveralIntegrations`: two integrations whose records interleave, and a stack trace after an `ERROR` record of one: the records are by time, and the stack trace is right after its record. It fails without the fix. - `CamelLogActionTest.closesTheLogsItRead` (Linux, macOS): 50 times `camel log` in one JVM opens no more files. Without the fix it leaves about 50 files open. - 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]
