-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
base: master
Are you sure you want to change the base?
Conversation
93b8792
to
90ba3c8
Compare
} | ||
|
||
// Maintain buffer size limit by removing oldest entries | ||
while self.buffer.len() > self.max_size { |
There was a problem hiding this comment.
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
90ba3c8
to
44a987b
Compare
Signed-off-by: Vjeran Grozdanic <[email protected]>
44a987b
to
d18413f
Compare
format.separator( | ||
prettytable::format::LinePosition::Title, | ||
prettytable::format::LineSeparator::new('-', '+', '+', '+'), | ||
); |
There was a problem hiding this comment.
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
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