Mageia Bugzilla – Attachment 3393 Details for
Bug 8722
logdrake does not work with system-journald
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Revised with improved layout
logdrake.patch (text/plain), 6.91 KB, created by
Derek Jennings
on 2013-01-17 23:53:11 CET
(
hide
)
Description:
Revised with improved layout
Filename:
MIME Type:
Creator:
Derek Jennings
Created:
2013-01-17 23:53:11 CET
Size:
6.91 KB
patch
obsolete
>--- /usr/sbin/logdrake 2013-01-16 21:18:34.000000000 +0000 >+++ logdrake 2013-01-17 22:45:15.000000000 +0000 >@@ -61,9 +61,10 @@ > my $mday = (localtime(time()))[3]; > $cal->select_day($mday); > my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); >-my $cal_mode = 0; >-my $cal_butt = gtksignal_connect(Gtk2::CheckButton->new(N("Show only for the selected day")), clicked => sub { $cal_mode = !$cal_mode; gtkset_sensitive($cal,$cal_mode) }); >- >+my @monthsdecimal = qw(01 02 03 04 05 06 07 08 09 10 11 12); >+my $cal_mode = 1; >+#my $cal_butt = gtksignal_connect(Gtk2::CheckButton->new(N("Show only for the selected day")), clicked => sub { $cal_mode = !$cal_mode; gtkset_sensitive($cal,$cal_mode) }); >+gtkset_sensitive($cal,$cal_mode); > ### menus definition > # the menus are not shown > # but they provides shiny shortcut like C-q (Broken: FIXME) >@@ -110,10 +111,17 @@ > "auth" => { file => "/var/log/auth.log", desc => N("_:this is the auth.log log file\nAuthentication") }, > "user" => { file => "/var/log/user.log", desc => N("_:this is the user.log log file\nUser") }, > "messages" => { file => "/var/log/messages", desc => N("_:this is the /var/log/messages log file\nMessages") }, >- "syslog" => { file => "/var/log/syslog", desc => N("_:this is the /var/log/syslog log file\nSyslog") }, >+ "syslog" => { file => "/usr/bin/journalctl", desc => N("_:this is the main system journal\nSystem log") }, > "explanations" => { file => "/var/log/explanations", desc => $explain_title } > ); > >+my %priority = ( >+ "info" => { loglevel => "6", desc => N("_:information log\nInfo") }, >+ "warning" => { loglevel => "4", desc => N("_:warning log\nWarning") }, >+ "error" => { loglevel => "3", desc => N("_:error log\nError") } >+); >+my $prioritylevel='6'; >+ > my $yy = gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("search")) , clicked => \&search),0); > > my $log_text = gtktext_insert(Gtk2::TextView->new, [ [ '' ] ]); >@@ -123,43 +131,64 @@ > #### far from window > > my %toggle; >- >+my %ptoggle; > gtkadd($my_win->{window}, > gtkpack_(Gtk2::VBox->new(0,0), > if_(!$::isEmbedded, 0, gtknew('Title1', label => N("A tool to monitor your logs"))), > if_(!$isFile, 0, gtkpack__(Gtk2::VBox->new(0,2), >- gtknew('Title2', label => N("Settings")), >+# gtknew('Title2', label => N("Settings")), > # N("Show lines"), > gtkpack__(Gtk2::HBox->new(0,0), > " " . N("Matching") . " ", my $e_yes = Gtk2::Entry->new, > " " . N("but not matching") . " ", my $e_no = Gtk2::Entry->new > ), > gtkpack_(Gtk2::HBox->new(0,0), >- 1, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Choose file")),2), >+ 1, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Log File")),2), > gtkpack(gtkset_border_width(Gtk2::VBox->new(0,0),0), > map { $toggle{$_} = gtksignal_connect(Gtk2::CheckButton->new($files{$_}{desc}), > clicked => sub { > $refcount_search++; > gtkset_sensitive($yy, $refcount_search); >- }); >- $toggle{$_}->set_sensitive(0) if !-f $files{$_}{file}; >- $toggle{$_}; >- } sort keys %files, >- ) >+ if ($ptoggle{info}) { >+ my $active = $toggle{syslog}->get_active ? 1 : 0; >+ foreach (keys %priority) { $ptoggle{$_}->set_sensitive($active) } >+ } >+ } >+ ); >+ $toggle{$_}->set_sensitive(0) if !-f $files{$_}{file}; >+ $toggle{$_}->set_active(1) if $_ eq 'syslog'; >+ $toggle{$_}; >+ } sort keys %files, >+ ), >+ ), >+ 1, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Priority Level")),2), >+ gtkpack(gtkset_border_width(Gtk2::VBox->new(0,0),0), >+ map { $ptoggle{$_} = gtksignal_connect(Gtk2::CheckButton->new($priority{$_}{desc}), >+ clicked => sub { >+ $refcount_search++; >+ gtkset_sensitive($yy, $refcount_search); >+ } >+ ); >+ $ptoggle{$_}->set_active(1) if $_ eq 'info'; >+ $ptoggle{$_}; >+ } sort keys %priority, >+ ), > ), >- 0, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Calendar")),2), >+ >+ 0, gtkadd(gtkset_border_width(Gtk2::Frame->new,2), > gtkpack__(gtkset_border_width(Gtk2::VBox->new(0,0),5), >- $cal_butt, $cal >+ $cal > ) > ) > ), >- $yy, >+# $yy, > ) > ), >- !$isExplain ? (0, gtknew('Title2', label => N("Content of the file")), >- 1, create_scrolled_window($log_text) >- ) : (1, create_scrolled_window($log_text)), >- 0, gtkadd(gtkset_border_width(gtkset_layout(Gtk2::HButtonBox->new, 'end'), 5), >+# !$isExplain ? (0, gtknew('Title2', label => N("Content of the file")), >+# 1, create_scrolled_window($log_text) >+# ) : (1, create_scrolled_window($log_text)), >+ 1, create_scrolled_window($log_text), >+ 0, gtkadd(gtkset_border_width(gtkset_layout(Gtk2::HButtonBox->new, 'end'), 5), $yy, gtkset_layout(Gtk2::HButtonBox->new, 'start'), > if_(!$isFile, gtksignal_connect(Gtk2::Button->new(N("Mail alert")), > clicked => sub { > eval { alert_config() }; >@@ -195,6 +224,15 @@ > if ($isFile) { > parse_file($File, $File); > } else { >+ my $p=3; >+ foreach (keys %priority) { >+ if ($ptoggle{$_}->get_active) { >+ if ($priority{$_}{loglevel} >= $p) { >+ $p = $priority{$_}{loglevel}; >+ $prioritylevel = $priority{$_}{loglevel}; >+ } >+ } >+ } > foreach (keys %files) { > parse_file($files{$_}{file}, $files{$_}{desc}) if $toggle{$_}->get_active; > } >@@ -212,7 +250,6 @@ > > sub parse_file { > my ($file, $descr) = @_; >- > $file =~ s/\.gz$//; > my ($pbar, $win_pb); > unless ($::isEmbedded && $isExplain) { >@@ -236,12 +273,17 @@ > $en =~ s/^\*$/.*/; > $ey = $ey . $Word if $isWord; > >- if ($cal_mode) { >- my (undef, $month, $day) = $cal->get_date; >- $ey = $months[$month] . "\\s{1,2}$day\\s.*$ey.*\n"; >- } >+ my ($year, $month, $day) = $cal->get_date; > >- my @all = -e $file ? catMaybeCompressed($file) : N("Sorry, log file isn't available!"); >+ my $logdate = "$year-$monthsdecimal[$month]-$day"; >+ my $logend = "$logdate 23:59:59"; >+ $ey = $months[$month] . "\\s{1,2}$day\\s.*$ey.*\n"; >+ my @all; >+ if ($file eq "/usr/bin/journalctl") { >+ @all = `journalctl --no-pager --since=$logdate --until="$logend" -p $prioritylevel`; >+ } else { >+ @all = -e $file ? catMaybeCompressed($file) : N("Sorry, log file isn't available!"); >+ } > > if ($isExplain) { > my (@t, $t);
--- /usr/sbin/logdrake 2013-01-16 21:18:34.000000000 +0000 +++ logdrake 2013-01-17 22:45:15.000000000 +0000 @@ -61,9 +61,10 @@ my $mday = (localtime(time()))[3]; $cal->select_day($mday); my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); -my $cal_mode = 0; -my $cal_butt = gtksignal_connect(Gtk2::CheckButton->new(N("Show only for the selected day")), clicked => sub { $cal_mode = !$cal_mode; gtkset_sensitive($cal,$cal_mode) }); - +my @monthsdecimal = qw(01 02 03 04 05 06 07 08 09 10 11 12); +my $cal_mode = 1; +#my $cal_butt = gtksignal_connect(Gtk2::CheckButton->new(N("Show only for the selected day")), clicked => sub { $cal_mode = !$cal_mode; gtkset_sensitive($cal,$cal_mode) }); +gtkset_sensitive($cal,$cal_mode); ### menus definition # the menus are not shown # but they provides shiny shortcut like C-q (Broken: FIXME) @@ -110,10 +111,17 @@ "auth" => { file => "/var/log/auth.log", desc => N("_:this is the auth.log log file\nAuthentication") }, "user" => { file => "/var/log/user.log", desc => N("_:this is the user.log log file\nUser") }, "messages" => { file => "/var/log/messages", desc => N("_:this is the /var/log/messages log file\nMessages") }, - "syslog" => { file => "/var/log/syslog", desc => N("_:this is the /var/log/syslog log file\nSyslog") }, + "syslog" => { file => "/usr/bin/journalctl", desc => N("_:this is the main system journal\nSystem log") }, "explanations" => { file => "/var/log/explanations", desc => $explain_title } ); +my %priority = ( + "info" => { loglevel => "6", desc => N("_:information log\nInfo") }, + "warning" => { loglevel => "4", desc => N("_:warning log\nWarning") }, + "error" => { loglevel => "3", desc => N("_:error log\nError") } +); +my $prioritylevel='6'; + my $yy = gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("search")) , clicked => \&search),0); my $log_text = gtktext_insert(Gtk2::TextView->new, [ [ '' ] ]); @@ -123,43 +131,64 @@ #### far from window my %toggle; - +my %ptoggle; gtkadd($my_win->{window}, gtkpack_(Gtk2::VBox->new(0,0), if_(!$::isEmbedded, 0, gtknew('Title1', label => N("A tool to monitor your logs"))), if_(!$isFile, 0, gtkpack__(Gtk2::VBox->new(0,2), - gtknew('Title2', label => N("Settings")), +# gtknew('Title2', label => N("Settings")), # N("Show lines"), gtkpack__(Gtk2::HBox->new(0,0), " " . N("Matching") . " ", my $e_yes = Gtk2::Entry->new, " " . N("but not matching") . " ", my $e_no = Gtk2::Entry->new ), gtkpack_(Gtk2::HBox->new(0,0), - 1, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Choose file")),2), + 1, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Log File")),2), gtkpack(gtkset_border_width(Gtk2::VBox->new(0,0),0), map { $toggle{$_} = gtksignal_connect(Gtk2::CheckButton->new($files{$_}{desc}), clicked => sub { $refcount_search++; gtkset_sensitive($yy, $refcount_search); - }); - $toggle{$_}->set_sensitive(0) if !-f $files{$_}{file}; - $toggle{$_}; - } sort keys %files, - ) + if ($ptoggle{info}) { + my $active = $toggle{syslog}->get_active ? 1 : 0; + foreach (keys %priority) { $ptoggle{$_}->set_sensitive($active) } + } + } + ); + $toggle{$_}->set_sensitive(0) if !-f $files{$_}{file}; + $toggle{$_}->set_active(1) if $_ eq 'syslog'; + $toggle{$_}; + } sort keys %files, + ), + ), + 1, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Priority Level")),2), + gtkpack(gtkset_border_width(Gtk2::VBox->new(0,0),0), + map { $ptoggle{$_} = gtksignal_connect(Gtk2::CheckButton->new($priority{$_}{desc}), + clicked => sub { + $refcount_search++; + gtkset_sensitive($yy, $refcount_search); + } + ); + $ptoggle{$_}->set_active(1) if $_ eq 'info'; + $ptoggle{$_}; + } sort keys %priority, + ), ), - 0, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Calendar")),2), + + 0, gtkadd(gtkset_border_width(Gtk2::Frame->new,2), gtkpack__(gtkset_border_width(Gtk2::VBox->new(0,0),5), - $cal_butt, $cal + $cal ) ) ), - $yy, +# $yy, ) ), - !$isExplain ? (0, gtknew('Title2', label => N("Content of the file")), - 1, create_scrolled_window($log_text) - ) : (1, create_scrolled_window($log_text)), - 0, gtkadd(gtkset_border_width(gtkset_layout(Gtk2::HButtonBox->new, 'end'), 5), +# !$isExplain ? (0, gtknew('Title2', label => N("Content of the file")), +# 1, create_scrolled_window($log_text) +# ) : (1, create_scrolled_window($log_text)), + 1, create_scrolled_window($log_text), + 0, gtkadd(gtkset_border_width(gtkset_layout(Gtk2::HButtonBox->new, 'end'), 5), $yy, gtkset_layout(Gtk2::HButtonBox->new, 'start'), if_(!$isFile, gtksignal_connect(Gtk2::Button->new(N("Mail alert")), clicked => sub { eval { alert_config() }; @@ -195,6 +224,15 @@ if ($isFile) { parse_file($File, $File); } else { + my $p=3; + foreach (keys %priority) { + if ($ptoggle{$_}->get_active) { + if ($priority{$_}{loglevel} >= $p) { + $p = $priority{$_}{loglevel}; + $prioritylevel = $priority{$_}{loglevel}; + } + } + } foreach (keys %files) { parse_file($files{$_}{file}, $files{$_}{desc}) if $toggle{$_}->get_active; } @@ -212,7 +250,6 @@ sub parse_file { my ($file, $descr) = @_; - $file =~ s/\.gz$//; my ($pbar, $win_pb); unless ($::isEmbedded && $isExplain) { @@ -236,12 +273,17 @@ $en =~ s/^\*$/.*/; $ey = $ey . $Word if $isWord; - if ($cal_mode) { - my (undef, $month, $day) = $cal->get_date; - $ey = $months[$month] . "\\s{1,2}$day\\s.*$ey.*\n"; - } + my ($year, $month, $day) = $cal->get_date; - my @all = -e $file ? catMaybeCompressed($file) : N("Sorry, log file isn't available!"); + my $logdate = "$year-$monthsdecimal[$month]-$day"; + my $logend = "$logdate 23:59:59"; + $ey = $months[$month] . "\\s{1,2}$day\\s.*$ey.*\n"; + my @all; + if ($file eq "/usr/bin/journalctl") { + @all = `journalctl --no-pager --since=$logdate --until="$logend" -p $prioritylevel`; + } else { + @all = -e $file ? catMaybeCompressed($file) : N("Sorry, log file isn't available!"); + } if ($isExplain) { my (@t, $t);
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 8722
:
3390
|
3391
|
3393
|
3509