summaryrefslogtreecommitdiffstats
path: root/logdrake
diff options
context:
space:
mode:
authorYves Duret <yduret@mandriva.com>2001-06-29 16:14:01 +0000
committerYves Duret <yduret@mandriva.com>2001-06-29 16:14:01 +0000
commit58e1c77f7090ca4114ab4fab4575824c14d433b2 (patch)
tree6a980fc37df6db5efda2c58c949ff67d9a58477b /logdrake
parente09a835d0623e6a460a259c19ebb954fc75d3459 (diff)
downloadcontrol-center-58e1c77f7090ca4114ab4fab4575824c14d433b2.tar
control-center-58e1c77f7090ca4114ab4fab4575824c14d433b2.tar.gz
control-center-58e1c77f7090ca4114ab4fab4575824c14d433b2.tar.bz2
control-center-58e1c77f7090ca4114ab4fab4575824c14d433b2.tar.xz
control-center-58e1c77f7090ca4114ab4fab4575824c14d433b2.zip
great upgrade
Diffstat (limited to 'logdrake')
-rwxr-xr-xlogdrake138
1 files changed, 61 insertions, 77 deletions
diff --git a/logdrake b/logdrake
index 031b38e1..8cc2ae7c 100755
--- a/logdrake
+++ b/logdrake
@@ -3,6 +3,7 @@
# Copyright (C) 2001 MandrakeSoft
# Yves Duret <yduret at mandrakesoft.com>
+# some code is Copyright: (C) 1999, Michael T. Babcock <mikebabcock@pobox.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,6 +25,7 @@ use interactive;
use standalone;
use common qw(:common :file :functional :system);
use any;
+use my_gtk qw(:helpers :wrappers);
use Gtk;
use Config;
@@ -46,6 +48,10 @@ local $_ = join '', @ARGV;
/-h/ and die "usage: logdrake [--version]\n";
/-version/ and die 'version: $Id$ '."\n";
+my $h=`hostname -s`;
+chop($h);
+
+
my $window = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel;
$window->signal_connect( delete_event => sub { $::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0) });
$window->set_title( _("logdrake") );
@@ -88,33 +94,53 @@ my $menubar = get_main_menu( $window );
my $n = Gtk::Gdk::Font->load("-misc-fixed-medium-r-*-*-*-100-*-*-*-*-*-*");
my $b = Gtk::Gdk::Font->load("-misc-fixed-bold-r-*-*-*-100-*-*-*-*-*-*");
-# Get the system color map and allocate the color red
-my $cmap = Gtk::Gdk::Colormap->get_system();
+my $white = my_gtk::gtkcolor(50400, 655, 20000);
+my $black = my_gtk::gtkcolor(0, 0, 0);
+my $red = my_gtk::gtkcolor(0xFFFF, 655, 655);
+my $green = my_gtk::gtkcolor(0x0, 0x9898,0x0);
+my $yellow = my_gtk::gtkcolor(0xFFFF, 0xD7D7, 0);
+my $blue = my_gtk::gtkcolor(655, 655, 0xFFFF);
+my $magenta = my_gtk::gtkcolor(0xFFFF, 655, 0xFFFF);
+my $purple = my_gtk::gtkcolor(0xA0A0, 0x2020, 0xF0F0);
+my $cyan = my_gtk::gtkcolor(0x0, 0x9898, 0x9898);
+my $darkgray = my_gtk::gtkcolor(0x2F2F, 0x4F4F, 0x4F4F);
-my $white = { red => 0xFFFF, green => 0xFFFF, blue =>0xFFFF};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($white)));
-my $black = { red => 0, green => 0, blue =>0};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($black)));
-my $red = { red => 0xFFFF, green => 0, blue =>0};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($red)));
-my $green = { red => 0xF, green => 0xFFF, blue =>0};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($green)));
-my $yellow = { red => 0xF, green => 0, blue =>0};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($yellow)));
-my $blue = { red => 0, green => 0, blue =>0xFFFF};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($blue)));
-my $magenta = { red => 0xF, green => 0, blue =>0};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($magenta)));
-my $purple = { red => 0xF, green => 0, blue =>0};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($purple)));
-my $cyan = { red => 0, green => 0xFFF, blue =>0xFFF};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($cyan)));
-my $darkgray = { red => 0xFFF, green => 0x, blue =>0};warn _("Couldn't allocate color\n") unless (defined($cmap->color_alloc($darkgray)));
+
+ # Define global terms:
+ # Define good notables:
+ my @word_good=("starting\n", "Freeing", "Detected", "starting.", "accepted.\n", "authenticated.\n", "Ready", "active", "reloading", "saved;", "restarting", "ONLINE\n");
+ my @word_warn=("dangling", "closed.\n", "Assuming", "root", "root\n", "exiting\n", "missing", "Ignored", "adminalert:", "deleting", "OFFLINE\n");
+ my @word_bad=("bad");
+my @word_note=("LOGIN", "DHCP_OFFER", "optimized", "reset:", "unloaded", "disconnected", "connect", "Successful", "registered\n");
+ my @line_good=("up", "DHCP_ACK", "Cleaned", "Initializing", "Starting", "success", "successfully", "alive", "found", "ONLINE\n");
+ my @line_warn=("warning:", "WARNING:", "invalid", "obsolete", "bad", "Password", "detected", "timeout", "timeout:", "attackalert:", "wrong", "Lame", "FAILED", "failing", "unknown", "obsolete", "stopped.\n", "terminating.", "disabled\n", "disabled", "Lost");
+ my @line_bad=("DENY", "lost", "shutting", "dead", "DHCP_NAK", "failure;", "Unable", "inactive", "terminating", "refused", "rejected", "down", "OFFLINE\n", "error\n", "ERROR\n", "ERROR:", "error", "ERROR", "error:", "failed:");
+
+ # Define specifics:
+ my @daemons=("named");
+
+ # Now define what we want to use when:
+ my $col_good = $green;
+ my $col_warn = $yellow;
+ my $col_bad = $red;
+ my $col_note = $purple;
+ my $col=$cyan;
######### font and colors end
+
+#### far from window
+
+
my $global_vbox = new Gtk::VBox();
$::isEmbedded or $global_vbox->pack_start (new Gtk::Label(_("see your log")), 0, 0, 0);
-#### far from window
-
### the tree
# Create a ScrolledWindow for the tree
my $tree_scrolled_win = new Gtk::ScrolledWindow();
-$tree_scrolled_win->set_usize(300, $::isEmbedded ? 0 : 175);
+#$tree_scrolled_win->set_usize(300, $::isEmbedded ? 0 : 175);
$global_vbox->pack_start( $tree_scrolled_win,0,0,0 );
$tree_scrolled_win->set_policy('automatic', 'automatic');
@@ -125,7 +151,6 @@ my $root_dir;
$tree_scrolled_win->add_with_viewport($tree);
$tree->set_selection_mode('single');
$tree->set_view_mode('item');
-
fill_tree ("");
my $log_frame = new Gtk::Frame( _("log") );
@@ -133,13 +158,12 @@ my $log = new Gtk::Text(undef, undef);
my $vscrollbar = new Gtk::VScrollbar( $log->vadj );
my $log_hbox = new Gtk::HBox (0, 0);
$log_hbox->border_width (5);
-$log_hbox->set_usize(300, 275);
$log_hbox->pack_start($log, 1, 1, 0);
$log_hbox->pack_start($vscrollbar, 0, 0, 0 );
-$log_frame->add ($log_hbox);
-$global_vbox->pack_start ($log_frame, 0, 0, 0);
+$log_frame->add($log_hbox);
+$global_vbox->pack_start($log_frame, 0, 0, 0);
-# $text->insert( $font, $foreground, $background, $string );
+ $log->insert($b,$yellow, undef,"meuhgyyyyyyyy\n");
### back to window
$window->add($global_vbox);
@@ -150,7 +174,6 @@ $::isEmbedded and kill USR2, $::CCPID;
Gtk->main;
-
#-------------------------------------------------------------
# tree functions
#-------------------------------------------------------------
@@ -224,66 +247,31 @@ sub select_item {
$log->backward_delete($log->get_length());
$file =~ s/\.gz$//;
$log->freeze();
-
+
foreach (catMaybeCompressed ($file)){
logcolorize($_);
}
$log->thaw();
}
-
sub log_output {
$log->insert($_[2],$_[0], undef,$_[1]);
}
##########################################################################################
sub logcolorize {
-
my ($thisline)=@_;
- # logcolorize.pl 1.0.8 - A PERL script to colorize log viewing
- # distributed under the GPL
- # Copyright: (C) 1999, Michael T. Babcock
- # <mikebabcock@pobox.com>
- # http://www.linuxsupportline.com/~pgp/linux/
- #
-
- # Define global terms:
- # Define good notables:
- my @word_good=("starting\n", "Freeing", "Detected", "starting.", "accepted.\n", "authenticated.\n", "Ready", "active", "reloading", "saved;", "restarting", "ONLINE\n");
- my @word_warn=("dangling", "closed.\n", "Assuming", "root", "root\n", "exiting\n", "missing", "Ignored", "adminalert:", "deleting", "OFFLINE\n");
- my @word_bad=("bad");
-my @word_note=("LOGIN", "DHCP_OFFER", "optimized", "reset:", "unloaded", "disconnected", "connect", "Successful", "registered\n");
- my @line_good=("up", "DHCP_ACK", "Cleaned", "Initializing", "Starting", "success", "successfully", "alive", "found", "ONLINE\n");
- my @line_warn=("warning:", "WARNING:", "invalid", "obsolete", "bad", "Password", "detected", "timeout", "timeout:", "attackalert:", "wrong", "Lame", "FAILED", "failing", "unknown", "obsolete", "stopped.\n", "terminating.", "disabled\n", "disabled", "Lost");
- my @line_bad=("DENY", "lost", "shutting", "dead", "DHCP_NAK", "failure;", "Unable", "inactive", "terminating", "refused", "rejected", "down", "OFFLINE\n", "error\n", "ERROR\n", "ERROR:", "error", "ERROR", "error:", "failed:");
-
- # Define specifics:
- my @daemons=("named");
-
- # Now define what we want to use when:
- my $col_good = $green;
- my $col_warn = $yellow;
- my $col_bad = $red;
- my $col_note = $purple;
- my $col=$cyan;
-
- my $col_norm = "\033[00m";
- my $col_background = "\033[07m";
- my $col_brighten = "\033[01m";
- my $col_underline = "\033[04m";
- my $col_blink = "\033[05m";
-
- # Resets to normal colours and moves to the left one column ...
- my $col_default = "$col_norm$white";
- my $datespace=0;
- s/(.{16})//;
+ # we get date & time if it is date & time (dmesg)
+ s/(\D{3} \d{2} \d\d:\d\d:\d\d )//;
$timestamp=$1;
- @rec = split;# (/ /, $_);
+ @rec = split;
log_output($cyan,$timestamp,$b); # date & time
- log_output($blue,"$rec[0] ",$b); # hostname
+ log_output(($rec[0] eq $h) ? $blue : $col,"$rec[0] ",$b); # hostname
+
+
if ($rec[1] eq "last") {
log_output($green," last message repeated ",$n);
log_output($green, $rec[4], $b);
@@ -304,20 +292,13 @@ my @word_note=("LOGIN", "DHCP_OFFER", "optimized", "reset:", "unloaded", "discon
for ($therest=(2); $therest<=$#rec; $therest++) {
+ $col=$cyan;
# Check for keywords to highlight
- for ($i=0; $i<=$#word_good; $i++) {
- $col=$col_good if ($word_good[$i] eq $rec[$therest]);
- }
- for ($i=0; $i<=$#word_warn; $i++) {
- $col=$col_warn if ($word_warn[$i] eq $rec[$therest]);
- }
- for ($i=0; $i<=$#word_bad; $i++) {
- $col=$col_bad if ($word_bad[$i] eq $rec[$therest]);
- }
- for ($i=0; $i<=$#word_note; $i++) {
- $col=$col_note if ($word_note[$i] eq $rec[$therest]);
- }
+ foreach (@word_good) { $col=$col_good if ($_ eq $rec[$therest]);}
+ foreach (@word_warn) { $col=$col_warn if ($_ eq $rec[$therest]);}
+ foreach (@word_bad) { $col=$col_bad if ($_ eq $rec[$therest]);}
+ foreach (@word_note) { $col=$col_note if ($_ eq $rec[$therest]);}
# # Watch for words that indicate entire lines should be highlighted
# for ($i=0; $i<=$#line_good; $i++) {
@@ -374,13 +355,13 @@ sub create_dialog {
my $button = new Gtk::Button _("OK");
$button->can_default(1);
- $button->signal_connect(clicked => sub { $ret = 1; $dialog->destroy(); Gtk->main_quit(); });
+ $button->signal_connect(clicked => sub { $ret=1; $dialog->destroy(); Gtk->main_quit(); });
$dialog->action_area->pack_start($button, 1, 1, 0);
$button->grab_default;
if ($c) {
my $button2 = new Gtk::Button _("Cancel");
- $button2->signal_connect(clicked => sub { $ret = 0; $dialog->destroy(); Gtk->main_quit(); });
+ $button2->signal_connect(clicked => sub { $ret=0; $dialog->destroy(); Gtk->main_quit(); });
$button2->can_default(1);
$dialog->action_area->pack_start($button2, 1, 1, 0);
}
@@ -402,6 +383,9 @@ sub destroy_window {
# log
# $Log$
+# Revision 1.3 2001/06/29 16:14:01 yduret
+# great upgrade
+#
# Revision 1.2 2001/06/28 10:50:27 yduret
# full support of color
#