summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYves Duret <yduret@mandriva.com>2001-08-13 09:57:55 +0000
committerYves Duret <yduret@mandriva.com>2001-08-13 09:57:55 +0000
commit85966fa57d0a3ca6cbf5d30b0f6f8bc68fad95df (patch)
treee0730ce864c355eca4357e544153f199a635651c
parentea3bbb3fc42dde4d744e86b14795005edee3bc6b (diff)
downloadcontrol-center-85966fa57d0a3ca6cbf5d30b0f6f8bc68fad95df.tar
control-center-85966fa57d0a3ca6cbf5d30b0f6f8bc68fad95df.tar.gz
control-center-85966fa57d0a3ca6cbf5d30b0f6f8bc68fad95df.tar.bz2
control-center-85966fa57d0a3ca6cbf5d30b0f6f8bc68fad95df.tar.xz
control-center-85966fa57d0a3ca6cbf5d30b0f6f8bc68fad95df.zip
added a timeout to watch file
-rwxr-xr-xlogdrake89
1 files changed, 58 insertions, 31 deletions
diff --git a/logdrake b/logdrake
index 1038fffc..8c613c93 100755
--- a/logdrake
+++ b/logdrake
@@ -19,6 +19,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#$|= 1;
+#open F, $ARGV[0];
+#while (1) {
+# print while <F>;
+# seek F, 0, 1;
+#}
+
+
use lib qw(/usr/lib/libDrakX);
use interactive;
use standalone;
@@ -59,7 +67,11 @@ local $_ = join '', @ARGV;
/-h/ and die sprintf( _("usage: logdrake [--version]\n"));
/-version/ and die 'version: $Id$ '."\n";
+$::isTail=1 if ($::isFile);
+#/-t/;
+$|= 1 if ($::isTail);
+print "isTail mode\n" if ($::isTail);
my $h=chomp_(`hostname -s`);
my $window = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel;
@@ -144,34 +156,33 @@ my %files = (
#### far from window
gtkadd($window,
gtkpack_(new Gtk::VBox(0,5),
- 0, _("A tool to see your log"),
- 0, gtkadd(new Gtk::Frame(_("Settings")),
- gtkpack__(new Gtk::VBox(0,5),
- gtkpack__(new Gtk::VBox(0,5),
-# _("Show lines"),
- gtkpack__(new Gtk::HBox(0,5),
- _("matching"), $e_yes = new Gtk::Entry(),
- _("but not matching"), $e_no = new Gtk::Entry()
- )
- ),
- # _("tips: you can use OR"),
- gtkpack_(new Gtk::HBox(0,0),
- 1, if_ (!$::isFile, gtkadd(gtkset_border_width(new Gtk::Frame(_("Choose file")),5),
+ 0, _("A tool to monitor your logs"),
+ if_ (!$::isFile, 0, gtkadd(new Gtk::Frame(_("Settings")),
+ gtkpack__(new Gtk::VBox(0,5),
+ gtkpack__(new Gtk::VBox(0,5),
+ # _("Show lines"),
+ gtkpack__(new Gtk::HBox(0,5),
+ _("matching"), $e_yes = new Gtk::Entry(),
+ _("but not matching"), $e_no = new Gtk::Entry()
+ )
+ ),
+ # _("tips: you can use OR"),
+ gtkpack_(new Gtk::HBox(0,0),
+ 1, gtkadd(gtkset_border_width(new Gtk::Frame(_("Choose file")),5),
gtkpack (gtkset_border_width(new Gtk::VBox(0,0),0),
map { ${"b_". $_} = new Gtk::CheckButton($files{$_}{desc}) } keys %files,
)
+ ),
+ 0, gtkadd(gtkset_border_width(new Gtk::Frame(_("Calendar")),5),
+ gtkpack__(gtkset_border_width(new Gtk::VBox(0,0),5),
+ $cal_butt, $cal
+ )
)
-
- ),
- 0, gtkadd(gtkset_border_width(new Gtk::Frame(_("Calendar")),5),
- gtkpack__(gtkset_border_width(new Gtk::VBox(0,0),5),
- $cal_butt, $cal
- )
- )
- ),
- gtksignal_connect(new Gtk::Button(_("search")), clicked => \&search)
- )
- ),
+ ),
+ gtksignal_connect(new Gtk::Button(_("search")), clicked => \&search)
+ )
+ )
+ ),
1, gtkadd(new Gtk::Frame(_("Content of the file")),
createScrolledWindow(my $log_text = new Gtk::Text(undef, undef))
),
@@ -179,12 +190,12 @@ gtkadd($window,
gtksignal_connect(new Gtk::Button (_("OK")), clicked=>sub{updateInit();updateAutologin();updateAurora();$::isEmbedded ? kill(USR1,$::CCPID) : Gtk->exit(0)}),
gtksignal_connect(new Gtk::Button ($::isEmbedded ? _("Cancel") : _("Quit")), clicked => sub {$::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0)})
)
-
+
)
);
-$::isEmbedded or gtkset_usize($log_text,200,200);
+$::isFile and gtkset_usize($log_text,400,500);
$window->realize;
$window->show_all();
search() if ($::isFile);
@@ -211,9 +222,9 @@ sub search {
sub parse_file {
my $file = $_[0];
+
+
$file =~ s/\.gz$//;
- my @all=catMaybeCompressed ($file);
- my $taille= @all;
my $i=0;
gtkadd(my $win_pb = (gtkset_modal new Gtk::Window(), 1),
gtkpack(new Gtk::VBox(5,0),
@@ -224,15 +235,17 @@ sub parse_file {
$win_pb->set_position('center');
$win_pb->realize();
$win_pb->show_all();
- my $ey= $e_yes->get_chars(0, -1);
- my $en= $e_no->get_chars(0, -1);
+ my $ey = $e_yes->get_chars(0, -1);
+ my $en = $e_no->get_chars(0, -1);
$ey =~ s/ OR /\|/;
if ($cal_mode) {
my ($year, $month, $day) = $cal->get_date();
$ey= $months[$month]."\\s{1,2}$day\\s.*$ey\n";
}
-
+
+ my @all=catMaybeCompressed ($file);
+ my $taille= @all;
foreach (@all) {
$i++;
if ($i % 10) {
@@ -246,6 +259,17 @@ sub parse_file {
}
$win_pb->destroy();
+ if ($::isTail) {
+ open F, $file or die "E: $!";
+ while (<F>) {}; #to prevent to output the file twice..
+ $log_text->set_point($log_text->get_length());
+ $timer = Gtk->timeout_add( 1000, \&input_callback);
+ }
+}
+
+sub input_callback {
+ logcolorize($_) while <F>;
+ seek F, 0, 1;
}
@@ -360,6 +384,9 @@ sub destroy_window {
# log
# $Log$
+# Revision 1.19 2001/08/13 09:57:55 yduret
+# added a timeout to watch file
+#
# Revision 1.18 2001/08/10 10:36:17 yduret
# fixes
#