summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog10
-rw-r--r--debian/files2
-rw-r--r--ivybanner226
3 files changed, 194 insertions, 44 deletions
diff --git a/debian/changelog b/debian/changelog
index 6434cb7..c81ec48 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ivybanner (1.1) unstable; urgency=low
+
+ * Possibilité d'afficher les logs d'une application spécifique
+
+ -- Daniel Etienne <etienne@cena.fr> Fri, 22 Aug 2003 14:51:47 +0200
+
ivybanner (1.0) unstable; urgency=low
* Initial release.
@@ -13,6 +19,4 @@ ivybanner (1.0) unstable; urgency=low
-- Daniel Etienne <etienne@cena.fr> Wed, 7 May 2003 16:38:15 +0200
-Local variables:
-mode: debian-changelog
-End:
+
diff --git a/debian/files b/debian/files
index 295fa03..60ed92a 100644
--- a/debian/files
+++ b/debian/files
@@ -1 +1 @@
-ivybanner_1.0_all.deb unknown optional
+ivybanner_1.1_all.deb unknown optional
diff --git a/ivybanner b/ivybanner
index 083b6b3..8519bd7 100644
--- a/ivybanner
+++ b/ivybanner
@@ -56,6 +56,8 @@ my $selected_button;
my $selected_demo;
my $view_button;
my $launch_button;
+my %apps;
+my $currentlogfile;
# parse options
#------------------------
@@ -154,7 +156,7 @@ my $logo_small =$mw->Photo ('logo-small',
my $logo_bg = $mw->Photo ('logo_bg',
-file => Tk::findINC('background.gif'));
-my ($fm1, $fm2, $fm3);
+my ($fm1, $fm2, $fm3, $tlog, $tlog2);
$fm1 = $mw->Frame->pack(-expand => 1, -fill => 'both');
my @buttonattr = (-width => 8, -height => 3,
@@ -587,29 +589,6 @@ sub viewLog {
my @packinfo = $fm2->packInfo;
$fm2->packForget();
$fm3 = $mw->Frame(-background => $darkbg)->pack(-expand => 1, -fill => 'both');
- my $t = $fm3->Scrolled('Text',
- -background => $bg,
- -relief => 'sunken',
- -foreground => $fg,
- @fontspec17,
- -height => 28,
- -width => 102,
- -borderwidth => 2,
- -highlightthickness => 3,
- -highlightbackground => $hlbg,
- -state => 'disabled',
- -scrollbars => 'oe');
- $t->Subwidget('yscrollbar')->configure(-width => 40,
- -borderwidth => 3,
- -relief => 'flat',
- -highlightthickness => 3,
- -troughcolor => $darkbg,
- -highlightbackground => $hlbg,
- -activebackground => $hlbg,
- -background => $bg);
-
- $t->tagConfigure('bold', -foreground => $hlbg);
- $t->place(-x => 50, -y => 120);
opendir PREFIX, $logdir;
my @files = readdir PREFIX;
closedir PREFIX;
@@ -643,22 +622,24 @@ sub viewLog {
my $l = $fm3->Label(@labelattr,
)->place(-x => 50, -y => 30);
- &readlog($logfiles[$cnt], $dates{$logfiles[$cnt]}, $t, $l) if @logfiles > 0;
-
-
$fm3->Button(@buttonattr,
-text => "back",
-command => sub {
$fm3->destroy;
$fm2->pack(@packinfo);
})->place(-x => 70, -y => 680);
+ my $select_button =
+ $fm3->Button(@buttonattr,
+ -text => "select...",
+ -command => \&selectappname,
+ )->place(-x => 400, -y => 680);
my $prev_button =
$fm3->Button(@buttonattr,
- -text => "prev",
+ -text => "previous\nlog",
)->place(-x => 600, -y => 680);
my $next_button =
$fm3->Button(@buttonattr,
- -text => "next",
+ -text => "next\nlog",
-state => 'disabled',
)->place(-x => 800, -y => 680);
if (@logfiles <= 1) {
@@ -666,43 +647,208 @@ sub viewLog {
$next_button->configure(-state => 'disabled');
}
$prev_button->configure(-command => sub {
+ $tlog2->destroy if Tk::Exists($tlog2);
$cnt--;
- &readlog($logfiles[$cnt], $dates{$logfiles[$cnt]}, $t, $l) if $cnt >= 0;
+ &readlog($logfiles[$cnt], $dates{$logfiles[$cnt]}, $l) if $cnt >= 0;
$prev_button->configure(-state => 'disabled') if $cnt <= 0;
$next_button->configure(-state => 'normal');
});
$next_button->configure(-command => sub {
+ $tlog2->destroy if Tk::Exists($tlog2);
$cnt++;
- &readlog($logfiles[$cnt], $dates{$logfiles[$cnt]}, $t, $l)
+ &readlog($logfiles[$cnt], $dates{$logfiles[$cnt]}, $l)
if $cnt <= $#logfiles;
$next_button->configure(-state => 'disabled') if $cnt >= $#logfiles;
$prev_button->configure(-state => 'normal');
});
-
+
+ &readlog($logfiles[$cnt], $dates{$logfiles[$cnt]}, $l) if @logfiles > 0;
} # end viewLog
+
+sub selectappname {
+ my $w = shift;
+ my $tl = $mw->Toplevel(-background => $darkbg);
+ $tl->title('messages selection');
+ $tl->resizable(0, 0);
+ my $fm = $tl->Frame(-background => $darkbg,
+ -highlightthickness => 3,
+ -highlightbackground => $hlbg,
+ )->pack(-side => 'top', -padx => 0, -pady => 0);
+ my $fm1 = $fm->Frame(-background => $darkbg)->pack(-side => 'top',
+ -padx => 10, -pady => 10);
+ my $fm2 = $fm->Frame(-background => $darkbg)->pack(-side => 'bottom');
+ my @labelattr = (-relief => 'flat',
+ -background => $darkbg,
+ -foreground => $fg,
+ -borderwidth => 0,
+ -highlightthickness => 0,
+ -height => 2,
+ @fontspec24);
+ my @buttonattr = (-relief => 'flat',
+ -background => $bg,
+ -foreground => $fg,
+ -borderwidth => 1,
+ -highlightbackground => $hlbg,
+ -highlightthickness => 3,
+ -height => 2,
+ -activebackground => $bg,
+ -activeforeground => $fg,
+ @fontspec24);
+ my @cbuttonattr = (@buttonattr, @fontspec17);
+ my $i = 0;
+ my $selapp = 'all';
+ for my $app (keys(%apps), 'all') {
+ my $col = $i % 3;
+ my $row = int($i/3);
+ $fm1->Radiobutton(@cbuttonattr, -selectcolor => $hlbg, -text => $app,
+ -variable => \$selapp,
+ -value => $app,
+ )->grid(-row => $row, -column => $col,
+ -padx => 5, -pady => 5, -sticky => 'nsew');
+ $i++;
+ }
+
+ $fm2->Button(@buttonattr, -text => 'yes',
+ -command => sub {
+ if ($selapp eq 'all') {
+ $tlog2->destroy if Tk::Exists($tlog2);
+ } else {
+ &readpartiallog($selapp);
+ }
+ $tl->destroy;
+ },
+ )->pack(-side => 'left', -padx => 20, -pady => 20,
+ -expand => 1, -fill => 'both');
+ $fm2->Button(@buttonattr, -text => 'cancel',
+ -command => sub { $tl->destroy },
+ )->pack(-side => 'left', -padx => 20, -pady => 20,
+ -expand => 1, -fill => 'both');
+ # placement at window center
+ $tl->update;
+ my ($x, $y) = ($mw->rootx, $mw->rooty);
+ $x += int($width/2 - $tl->width/2);
+ $y += int($height/2 - $tl->height/2);
+ $tl->geometry('+'.$x.'+'.$y);
+ $tl->grab;
+
+} # end selectappname
+
+
sub readlog {
- my ($file, $date, $t, $l) = @_;
+ # il est plus rapide de recréer un widget Text que de le vider de son
+ # contenu et le remettre à jour !!
+ my ($file, $date, $l) = @_;
$file = $logdir."/".$file;
- $l->configure(-text => $date);
+ $currentlogfile = $file;
+ $tlog2->destroy if Tk::Exists($tlog2);
+ $fm3->update;
+ $tlog = $fm3->Scrolled('Text',
+ -background => $bg,
+ -relief => 'sunken',
+ -foreground => $fg,
+ @fontspec17,
+ -height => 28,
+ -width => 102,
+ -borderwidth => 2,
+ -highlightthickness => 3,
+ -highlightbackground => $hlbg,
+ -state => 'disabled',
+ -scrollbars => 'oe');
+ $tlog->Subwidget('yscrollbar')->configure(-width => 40,
+ -borderwidth => 3,
+ -relief => 'flat',
+ -highlightthickness => 3,
+ -troughcolor => $darkbg,
+ -highlightbackground => $hlbg,
+ -activebackground => $hlbg,
+ -background => $bg);
+
+ $tlog->tagConfigure('bold', -foreground => $hlbg);
+ $tlog->place(-x => 50, -y => 120);
+
+ $l->configure(-text => "loading...");
+ $l->update;
open(FILE, $file) or warn "cannot read file '$file'\n";
- $t->configure(-state => 'normal');
- $t->delete('0.0', 'end');
+ $tlog->configure(-state => 'normal');
+ $tlog->update;
while (<FILE>) {
my @msg;
+ my $i = 0;
while (/\c[\[1m(.*?)\c[\[m([^\c[]*)/g) {
- $t->insert('end', $1, 'bold');
- $t->insert('end', $2);
+ my $app = $1;
+ my $msg = $2;
+ #print "app=[$app] [$msg]\n";
+ if ($app =~ /^\S+\s*$/) {
+ $apps{$app} = 1 if $i == 0;
+ $tlog->insert('end', "$app", 'bold', "$msg");
+ } else {
+ $tlog->insert('end', "$app $msg");
+ }
+ $i++;
}
}
- $t->see('end');
- $t->configure(-state => 'disabled');
+ $tlog->see('end');
+ $tlog->configure(-state => 'disabled');
+ $l->configure(-text => $date);
close FILE;
} # end readlog
+sub readpartiallog {
+ my ($selapp) = @_;
+ $tlog2->destroy if Tk::Exists($tlog2);
+ $fm3->update;
+ $tlog2 = $fm3->Scrolled('Text',
+ -background => $bg,
+ -relief => 'sunken',
+ -foreground => $fg,
+ @fontspec17,
+ -height => 28,
+ -width => 102,
+ -borderwidth => 2,
+ -highlightthickness => 3,
+ -highlightbackground => $hlbg,
+ -state => 'disabled',
+ -scrollbars => 'oe');
+
+ $tlog2->Subwidget('yscrollbar')->configure(-width => 40,
+ -borderwidth => 3,
+ -relief => 'flat',
+ -highlightthickness => 3,
+ -troughcolor => $darkbg,
+ -highlightbackground => $hlbg,
+ -activebackground => $hlbg,
+ -background => $bg);
+
+ $tlog2->tagConfigure('bold', -foreground => $hlbg);
+ $tlog2->place(-x => 50, -y => 120);
+
+ $tlog2->configure(-state => 'normal');
+ open(FILE, $currentlogfile) or warn "cannot read file '$currentlogfile'\n";
+ while (<FILE>) {
+ my @msg;
+ my $i = 0;
+ while (/\c[\[1m(.*?)\c[\[m([^\c[]*)/g) {
+ my $app = $1;
+ last if $i == 0 and $app ne $selapp;
+ my $msg = $2;
+ #print "app=[$app] [$msg]\n";
+ if ($app =~ /^\S+\s*$/) {
+ $tlog2->insert('end', "$app", 'bold', "$msg");
+ } else {
+ $tlog2->insert('end', "$app $msg");
+ }
+ $i++;
+ }
+ }
+ $tlog2->see('end');
+ $tlog2->configure(-state => 'disabled');
+ $tlog2->update;
+
+} # end readpartiallog
sub ison {
my $b = shift;