Show System Backup type in logs page
Add [TYPE:SYSBACKUP] marker to sysbackup log output. The logs page detects this in the first 5 lines and displays "System" badge instead of "Backup". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1373,6 +1373,7 @@ cmd_sysbackup() {
|
||||
load_config "$config_file"
|
||||
validate_config || die "Invalid configuration"
|
||||
init_logging
|
||||
log_info "[TYPE:SYSBACKUP] System backup started"
|
||||
|
||||
local dry_run=false
|
||||
has_flag dry-run "$@" && dry_run=true
|
||||
|
||||
@@ -61,7 +61,7 @@ sub show_list {
|
||||
name => $entry,
|
||||
size => $stat[7] // 0,
|
||||
mtime => $stat[9] // 0,
|
||||
type => ($entry =~ /^cron-/) ? 'Cron' : 'Backup',
|
||||
type => ($entry =~ /^cron-/) ? 'Cron' : _detect_log_type($path),
|
||||
status => $status,
|
||||
};
|
||||
}
|
||||
@@ -96,7 +96,9 @@ sub show_list {
|
||||
|
||||
for my $f (@page_files) {
|
||||
my $esc_name = GnizaWHM::UI::esc($f->{name});
|
||||
my $badge = $f->{type} eq 'Cron' ? 'badge-neutral' : 'badge-info';
|
||||
my $badge = $f->{type} eq 'Cron' ? 'badge-neutral'
|
||||
: $f->{type} eq 'System' ? 'badge-warning'
|
||||
: 'badge-info';
|
||||
my $date = _format_time($f->{mtime});
|
||||
my $size = _human_size($f->{size});
|
||||
my $href = 'logs.cgi?file=' . _uri_escape($f->{name});
|
||||
@@ -321,6 +323,21 @@ sub _valid_log_filename {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub _detect_log_type {
|
||||
my ($path) = @_;
|
||||
if (open my $fh, '<', $path) {
|
||||
while (my $line = <$fh>) {
|
||||
if ($line =~ /\[TYPE:SYSBACKUP\]/) {
|
||||
close $fh;
|
||||
return 'System';
|
||||
}
|
||||
last if $. > 5;
|
||||
}
|
||||
close $fh;
|
||||
}
|
||||
return 'Backup';
|
||||
}
|
||||
|
||||
sub _detect_log_status {
|
||||
my ($path) = @_;
|
||||
return 'Success' unless -f $path;
|
||||
|
||||
Reference in New Issue
Block a user