Fix to redirect straight to log view or show error

This commit is contained in:
Ilia Ross
2024-05-27 13:57:27 +03:00
parent 75e9323429
commit 1b1ac686e3
4 changed files with 34 additions and 18 deletions

View File

@@ -1,3 +1,4 @@
skip_index=1
lines=1000
others=0
reverse=1

View File

@@ -1,3 +1,4 @@
skip_index=Open log view on module load,1,1-Yes,0-No
lines=Default number of lines to display,0,6
refresh=Seconds between log view refreshes,3,Never
others=Show logs from other modules,1,1-Yes,0-No

View File

@@ -4,14 +4,6 @@
require './logviewer-lib.pl';
&ui_print_header($text{'index_subtitle'}, $text{'index_title'}, "", undef, 1, 1, 0,
&help_search_link("systemd-journal journalctl", "man", "doc"));
if (!&has_command('journalctl')) {
# Not installed
&ui_print_endpage(&text('index_econf', "<tt>$config{'syslog_conf'}</tt>", "../config.cgi?$module_name"));
}
# Display syslog rules
my @col0;
my @col1;
@@ -128,16 +120,38 @@ foreach $e (&extra_log_files()) {
# Print sorted table with logs files and commands
my @acols = (@col0, @col1, @col2, @col3);
my $print_header = sub {
# Print the header
&ui_print_header($text{'index_subtitle'}, $text{'index_title'}, "", undef, 1, 1, 0,
&help_search_link("systemd-journal journalctl", "man", "doc"));
};
# If no logs are available just show the message
if (!@acols) {
$print_header->();
&ui_print_endpage($text{'index_elogs'});
}
# If we jump directly to logs just redirect
if ($config{'skip_index'} == 1) {
my $link;
$link = $acols[0]->[2];
$link =~ s/.*?href\s*=\s*(["']?)(?<link>[^"'\s>]+).*\1?/$+{link}/g;
if ($link) {
&redirect($link);
exit;
}
}
# Print the header
$print_header->();
print &ui_columns_start( @acols ? [
$text{'index_to'},
$text{'index_rule'}, "" ] : [ ], 100);
if (@acols) {
foreach my $col (@acols) {
print &ui_columns_row($col);
}
}
else {
print &ui_columns_row([$text{'index_elogs'}], [" colspan='3' style='text-align: center'"], 3);
foreach my $col (@acols) {
print &ui_columns_row($col);
}
print &ui_columns_end();
print "<p>\n";

View File

@@ -1,7 +1,7 @@
index_title=System Logs
index_elogs=No logs were found to display
index_to=Log destination
index_rule=Messages selected
index_elogs=The <tt>journalctl</tt> command is not available on your system, and other logs are configured not to be displayed in the module configuration.
index_to=Log
index_rule=Description
index_file=File $1
index_cmd=Output from $1
index_return=system logs