Skip to content

feat: updated log viewer#58

Open
ronnakamoto wants to merge 1 commit intoLayerTwo-Labs:masterfrom
ronnakamoto:new-log-viewer
Open

feat: updated log viewer#58
ronnakamoto wants to merge 1 commit intoLayerTwo-Labs:masterfrom
ronnakamoto:new-log-viewer

Conversation

@ronnakamoto
Copy link
Copy Markdown

@ronnakamoto ronnakamoto commented May 17, 2025

This PR includes significant improvements to the log viewer.

Thunder.Log.Viewer.mov

Comment thread app/gui/console_logs.rs
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum LogLevel {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you just use tracing::Level here?

Comment thread app/gui/console_logs.rs

fn color(&self) -> Color32 {
match self {
LogLevel::Error => Color32::from_rgb(255, 85, 85), // Bright red
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These colors should be defined as consts somewhere

Comment thread app/gui/console_logs.rs
}

impl LogEntry {
fn parse(line: &str) -> Option<Self> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of parsing log lines, we should refactor LineBuffer to store unformatted log lines, and then you won't need LogEntry either

Comment thread app/gui/console_logs.rs
}
}

fn filtered_logs(&self) -> Vec<&LogEntry> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Filtering should be set in the tracing filter for the log buffer, in app/main.rs.

Comment thread app/gui/console_logs.rs

// Main log view
// Create a clone of the filtered logs to avoid borrow issues
let filtered_logs: Vec<LogEntry> = self.filtered_logs().iter().map(|&log| log.clone()).collect();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cloning the logs could be extremely expensive! This should be avoided if possible

Comment thread app/gui/console_logs.rs
&& !self.running_command.load(atomic::Ordering::SeqCst),
command_input,
// Parse logs from the line buffer
self.parse_logs();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Parsing all logs from the line buffer on each update could be very expensive. If you must process the log lines, either do it in the line buffer, or use streams so that only new log lines get parsed

Comment thread app/gui/console_logs.rs
);

if command_input_resp.ctx.input_mut(|input| {
input.consume_key(Modifiers::NONE, Key::Enter)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How can the user input a multiline command? I think it is best to preserve the existing behavior with Shift+Enter

Comment thread app/gui/console_logs.rs
}

if ui.button("Run").clicked() && app.is_some() && !self.running_command.load(atomic::Ordering::SeqCst) {
self.console_command(app.unwrap());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If it is safe to unwrap app here, then you should also do so when accepting a new command with the Enter key

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.

2 participants