Mageia Bugzilla – Attachment 3391 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]
Patch for logdrake to read system-journald
logdrake.patch (text/plain), 6.42 KB, created by
Derek Jennings
on 2013-01-17 14:28:10 CET
(
hide
)
Description:
Patch for logdrake to read system-journald
Filename:
MIME Type:
Creator:
Derek Jennings
Created:
2013-01-17 14:28:10 CET
Size:
6.42 KB
patch
obsolete
>--- /usr/sbin/logdrake 2013-01-16 21:18:34.000000000 +0000 >+++ logdrake 2013-01-17 14:26:17.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,7 +131,7 @@ > #### 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"))), >@@ -135,21 +143,37 @@ > " " . 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, >- ) >+ } >+ ); >+ $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 > ) > ) > ), >@@ -195,6 +219,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 +245,6 @@ > > sub parse_file { > my ($file, $descr) = @_; >- > $file =~ s/\.gz$//; > my ($pbar, $win_pb); > unless ($::isEmbedded && $isExplain) { >@@ -236,12 +268,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); >@@ -437,8 +474,8 @@ > N("Please enter your email address below ") . "\n" . > N("and enter the name (or the IP) of the SMTP server you wish to use"), > data => [ >- { label => N("Email address"), val => \$options{MAIL} }, >- { label => N("Email server"), val => \$options{SMTP} }, >+ { label => "Email address", val => \$options{MAIL} }, >+ { label => "Email server", val => \$options{SMTP} }, > ], > complete => sub { > if ($options{MAIL} !~ /[\w.-]*\@[\w.-]/ && !member($options{MAIL}, map { $_->[0] } list_passwd())) {
--- /usr/sbin/logdrake 2013-01-16 21:18:34.000000000 +0000 +++ logdrake 2013-01-17 14:26:17.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,7 +131,7 @@ #### 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"))), @@ -135,21 +143,37 @@ " " . 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, - ) + } + ); + $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 ) ) ), @@ -195,6 +219,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 +245,6 @@ sub parse_file { my ($file, $descr) = @_; - $file =~ s/\.gz$//; my ($pbar, $win_pb); unless ($::isEmbedded && $isExplain) { @@ -236,12 +268,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); @@ -437,8 +474,8 @@ N("Please enter your email address below ") . "\n" . N("and enter the name (or the IP) of the SMTP server you wish to use"), data => [ - { label => N("Email address"), val => \$options{MAIL} }, - { label => N("Email server"), val => \$options{SMTP} }, + { label => "Email address", val => \$options{MAIL} }, + { label => "Email server", val => \$options{SMTP} }, ], complete => sub { if ($options{MAIL} !~ /[\w.-]*\@[\w.-]/ && !member($options{MAIL}, map { $_->[0] } list_passwd())) {
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 8722
:
3390
|
3391
|
3393
|
3509