Unify log viewing with configurable script command
All checks were successful
Build and Release / build-and-release (push) Successful in 2m37s

Replace separate J/L keys with single L key that calls configurable
service_logs_cmd from dashboard config. Script handles both journalctl
and custom log files automatically based on service configuration.

Update status bar to show all available keybindings including
previously missing backup and terminal commands.
This commit is contained in:
Christoffer Martinsson 2025-11-20 11:00:38 +01:00
parent cd5ef65d3d
commit 2384f7f9b9
5 changed files with 13 additions and 40 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard-agent"
version = "0.1.92"
version = "0.1.93"
edition = "2021"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard"
version = "0.1.92"
version = "0.1.93"
edition = "2021"
[dependencies]

View File

@ -57,6 +57,7 @@ pub struct SshConfig {
pub rebuild_user: String,
pub rebuild_cmd: String,
pub service_manage_cmd: String,
pub service_logs_cmd: String,
}
/// Service log file configuration per host

View File

@ -310,16 +310,15 @@ impl TuiApp {
.ok(); // Ignore errors, tmux will handle them
}
}
KeyCode::Char('J') => {
// Show service logs via journalctl in tmux split window
KeyCode::Char('L') => {
// Show service logs via script in tmux split window
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
let connection_ip = self.get_connection_ip(&hostname);
let journalctl_command = format!(
"echo 'Viewing logs for service: {} on {}' && ssh -tt {}@{} 'sudo journalctl -u {}.service -f --no-pager -n 50'",
service_name,
hostname,
let logs_command = format!(
"ssh -tt {}@{} '{} {}'",
self.config.ssh.rebuild_user,
connection_ip,
self.config.ssh.service_logs_cmd,
service_name
);
@ -328,39 +327,11 @@ impl TuiApp {
.arg("-v")
.arg("-p")
.arg("30")
.arg(&journalctl_command)
.arg(&logs_command)
.spawn()
.ok(); // Ignore errors, tmux will handle them
}
}
KeyCode::Char('L') => {
// Show custom service log file in tmux split window
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
// Check if this service has a custom log file configured
if let Some(host_logs) = self.config.service_logs.get(&hostname) {
if let Some(log_config) = host_logs.iter().find(|config| config.service_name == service_name) {
let connection_ip = self.get_connection_ip(&hostname);
let tail_command = format!(
"echo 'Viewing custom logs for service: {} on {}' && ssh -tt {}@{} 'sudo tail -n 50 -f {}'",
service_name,
hostname,
self.config.ssh.rebuild_user,
connection_ip,
log_config.log_file_path
);
std::process::Command::new("tmux")
.arg("split-window")
.arg("-v")
.arg("-p")
.arg("30")
.arg(&tail_command)
.spawn()
.ok(); // Ignore errors, tmux will handle them
}
}
}
}
KeyCode::Char('w') => {
// Wake on LAN for offline hosts
if let Some(hostname) = self.current_host.clone() {
@ -747,9 +718,10 @@ impl TuiApp {
shortcuts.push("Tab: Host".to_string());
shortcuts.push("↑↓/jk: Select".to_string());
shortcuts.push("r: Rebuild".to_string());
shortcuts.push("B: Backup".to_string());
shortcuts.push("s/S: Start/Stop".to_string());
shortcuts.push("J: Logs".to_string());
shortcuts.push("L: Custom".to_string());
shortcuts.push("L: Logs".to_string());
shortcuts.push("t: Terminal".to_string());
shortcuts.push("w: Wake".to_string());
// Always show quit

View File

@ -1,6 +1,6 @@
[package]
name = "cm-dashboard-shared"
version = "0.1.92"
version = "0.1.93"
edition = "2021"
[dependencies]