Skip to content

feat(logs): support log streaming #2666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

feat(logs): support log streaming #2666

wants to merge 14 commits into from

Conversation

vgrozdanic
Copy link
Member

@vgrozdanic vgrozdanic commented Jul 31, 2025

Adds support for live streaming of logs by polling the API every 2 seconds (by default).

Polling interval is configurable via command line argument.

In order to show streamed logs as a table, it implements new methods on Table struct:

  • print_table_start - this prints both the header and the first few rows (as many as it was fetched in the first API call). This combines two operations because if we would only print header without any rows, than the table would look weirdly formatted, since the header doesn't know how wide it should be without any data in it. This method prints the table without the bottom border.
  • print_rows_only - Prints only the rows in the table, without the header, and without the bottom and upper border

}

// Maintain buffer size limit by removing oldest entries
while self.buffer.len() > self.max_size {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is done to prevent OOM in case this keeps running for a long time

Signed-off-by: Vjeran Grozdanic <[email protected]>
Comment on lines +128 to +131
format.separator(
prettytable::format::LinePosition::Title,
prettytable::format::LineSeparator::new('-', '+', '+', '+'),
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do custom formatting, because every other formatting adds empty lines after printing out the table. We want it to seem like it's infinite table, without empty lines in between printing multiple rows, so we need to use FORMAT_NO_BORDER, and define our own line separator for header

Base automatically changed from vg/add-logs-command to master August 6, 2025 11:42
@vgrozdanic vgrozdanic marked this pull request as ready for review August 12, 2025 12:51
@vgrozdanic vgrozdanic requested review from szokeasaurusrex and a team as code owners August 12, 2025 12:51
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.

1 participant