Leser: 1
3 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#! /usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::ROText;
my $logfile = 'E:\apacheweb\8084_develop.perl-community.de\log\error.log';
my $mw = MainWindow->new();
my $buttonFrame = $mw->Frame()->pack(-side => 'top', -fill => 'x', -expand => 1);
$buttonFrame->Button(-text => 'Quit', -command => sub { $mw->destroy })
->pack(-side => 'right');
my $text = $mw->Scrolled('ROText', -scrollbars => 'e',
-width => 100, -height => 50, -wrap => 'word')
->pack(-fill => 'both', -expand => 1);
$buttonFrame->Button(-text => 'Ans Ende scrollen',
-command => sub { $text->see('end') })
->pack(-side => 'left');
$text->tagConfigure('bold', -font => 'Courier 10 bold');
$text->tagConfigure('red', -background => 'red');
$text->tagConfigure('yellow', -background => 'yellow');
unless (open (LOG, $logfile)) {
die "Error: couldn't read '$logfile': $!\n";
} # unless
&UpdateFromLog();
MainLoop;
close(LOG);
# ------------------------------------------------------------
sub UpdateFromLog {
seek(LOG, 0, 1);
my $found = 0;
while (<LOG>) {
chomp($_);
$found = 1;
# try to parse line
if (my ($date, $mode, $client, $message) =
/^
\[ ([^\]]+) \]
\s+
\[ ([^\]]+) \]
\s+
\[ ([^\]]+) \]
\s+
(.+)
$/x) {
$text->insert('end', "$date\t$mode\t$client\n", 'bold');
$text->insert('end', "$message\n", $mode eq 'error' ? 'red': 'yellow');
} # if
elsif (my ($date3, $mode3, $message3) =
/^
\[ ([^\]]+) \]
\s+
\[ ([^\]]+) \]
\s+
(.+)
$/x) {
$text->insert('end', "$date3\t$mode3\n", 'bold');
$text->insert('end', "$message3\n", $mode3 eq 'error' ? 'red': 'yellow');
} # elsif
elsif (my ($date2, $file, $message2) =
/^
\[ ([^\]]+) \]
\s+
(\S+)
\s+
(.+)
$/x ) {
$text->insert('end', "$date2\t$file\n", 'bold');
$text->insert('end', "$message2\n", 'yellow');
} # elsif
# if not possible, output line
else {
$text->insert('end', "$_\n");
} # else
}
$found and $text->see('end');
$mw->after(1000, \&UpdateFromLog);
} # UpdateFromLog
# ------------------------------------------------------------
3 Einträge, 1 Seite |