Leser: 7
|< 1 2 3 4 ... 8 >| | 74 Einträge, 8 Seiten |
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
return bless({});
sub logOutputStrings
{
my($self,$main,$commands) = @_;
my @commands = grep {$main->{settings}{log_messages}{(split(/\|/,$_->[2]))[0]}} @$commands;
return if $#commands<0;
$main->open(local *LOG, '>>'.$main->translateName('vardir::messages.log'));
foreach (@commands)
{
my $user = defined($_->[0])?$_->[0]:'';
my $room = defined($_->[1])?$_->[1]:'';
print LOG "$main->{runtime}{now}|$user|$room|$_->[2]\n";
}
if ($main->{settings}{max_messageslog_size}>0 && $main->{settings}{messageslog_backups_count}>0 && tell(LOG)>$main->{settings}{max_messageslog_size})
{ # rotate log now
unlink($main->translateName("vardir::messages.$main->{settings}{messageslog_backups_count}.log"));
for (my $i=$main->{settings}{messageslog_backups_count}-1;$i>=0;$i--)
{
my $j=$i+1;
rename($main->translateName("vardir::messages.$i.log"),$main->translateName("vardir::messages.$j.log"));
}
$main->close(*LOG);
rename($main->translateName("vardir::messages.log"),$main->translateName("vardir::messages.1.log"));
}
else
{
$main->close(*LOG);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1164963438||lobby|entered|trioxx|TrioxX|lobby
1164963450||lobby|leaved|trioxx|TrioxX|lobby
1164963530||lobby|entered|trioxx|TrioxX|lobby
1164963537||lobby|leaved|trioxx|TrioxX|lobby
1164963580||lobby|entered|trioxx|TrioxX|lobby
1164963588||lobby|leaved|trioxx|TrioxX|lobby
1164963742||lobby|entered|trioxx|TrioxX|lobby
1164963758||lobby|leaved|trioxx|TrioxX|lobby
1164963823||lobby|entered|trioxx|TrioxX|lobby
1164963832||lobby|leaved|trioxx|TrioxX|lobby
1164963945||lobby|entered|trioxx|TrioxX|lobby
1164964076||lobby|leaved|trioxx|TrioxX|lobby
1164964079||lobby|entered|trioxx|TrioxX|lobby
1164964088||lobby|leaved|trioxx|TrioxX|lobby
1165086722||lobby|entered|trioxx|TrioxX|lobby
1165086778||lobby|leaved|trioxx|TrioxX|lobby
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
sub log_handler
{
my($self,$main) = @_;
$main->{template_vars}{backaddr} = 'javascript:history.back()';
$main->fatal_error('nopermission') unless $main->hasPermission('admin_log');
my $lognum = int($main->{input}{log});
my $filename = $main->translateName('vardir::messages.' . ($lognum ? "$lognum." : '') . 'log');
$main->open(local *LOG,$filename) || $main->fatal_error('couldnotopen',{file => $filename});
my @entries = <LOG>;
$main->close(*LOG);
$main->{template_vars}{log_filename}=$filename;
$main->printTemplate('admin/log_top');
my %rooms = map {$_ => 1} split(/\s+/,$main->{input}{rooms});
foreach (@entries)
{
s/[\n\r]//g;
my ($time,$user,$room,$message) = split(/\|/,$_,4);
if (($user eq '' && $room eq '' && $main->{input}{show_global})
|| ($user ne '' && $main->{input}{show_private})
|| ($room ne '' && !$rooms{$room} && $main->{input}{show_nonexistent})
|| ($room ne '' && $main->{input}{"show_room.$room"}))
{
$message = $main->fromOutputString($message);
if ($main->{input}{"show_template.$message->{template}"})
{
$message->{time} = $time;
$message->{_user} = $user;
$message->{_room} = $room;
$main->{template_vars}{params}=$message;
my $output = '';
$main->parseTemplate('log/'.$message->{template})->process($main,\$output);
print $output;
}
}
}
my $output = "\n";
$main->parseTemplate('admin/log_bottom')->process($main,\$output);
print $output;
}
tail -10 datei
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
#!/usr/bin/perl
use strict;
use warnings 'all';
# die Informationen die du dir mit:
# open(IN, "<", $file) or die "Die Datei '$file' konnte nicht zum Lesen geoeffnet werden.";
# chomp(@arr = <IN>);
# close IN;
# geholt hast:
my @arr = qw(1164963438||lobby|entered|trioxx|TrioxX|lobby
1164963450||lobby|leaved|trioxx|TrioxX|lobby
1164963530||lobby|entered|trioxx|TrioxX|lobby
1164963537||lobby|leaved|trioxx|TrioxX|lobby
1164963580||lobby|entered|trioxx|TrioxX|lobby
1164963588||lobby|leaved|trioxx|TrioxX|lobby
1164963742||lobby|entered|trioxx|TrioxX|lobby
1164963758||lobby|leaved|trioxx|TrioxX|lobby
1164963823||lobby|entered|trioxx|TrioxX|lobby
1164963832||lobby|leaved|trioxx|TrioxX|lobby
1164963945||lobby|entered|trioxx|TrioxX|lobby
1164964076||lobby|leaved|trioxx|TrioxX|lobby
1164964079||lobby|entered|trioxx|TrioxX|lobby
1164964088||lobby|leaved|trioxx|TrioxX|lobby
1165086722||lobby|entered|trioxx|TrioxX|lobby
1165086778||lobby|leaved|trioxx|TrioxX|lobby);
# die letzten 10 Zeilen davon verwenden:
my @arr2;
for (0..9)
{
$_ = 10-$_;
push(@arr2, $arr[-$_]);
}
foreach my$line (@arr2)
{
# Informationen auslesen:
my @infos = split /\|\|/, $line;
@infos = ($infos[0], (split /\|/, $infos[1]));
# in @infos steht für die erste Zeile jetzt folgendes:
# 1164963742, lobby, entered, trioxx, TrioxX, lobby
# das kannst du, wenn du möchtest noch einem Hash zuweisen,
# dann wird deutlicher was das fuer infos sind
my %infos = (number => $infos[0],
place => $infos[1],
action => $infos[2],
member => $infos[3],
name => $infos[4],
from => $infos[5]);
# Informationen anzeigen:
print "\nINFOS:\n";
print "$_: ". $infos{$_} ."\n" foreach (keys %infos);
}
|< 1 2 3 4 ... 8 >| | 74 Einträge, 8 Seiten |