line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# $Id: Logger.pm,v 1.5 2004/03/08 10:43:58 eserte Exp $ |
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright (C) 2002 Slaven Rezic. All rights reserved. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package WE_Frontend::Logger; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
997
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
15
|
1
|
|
|
1
|
|
5
|
use vars qw($logfile); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
16
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
38
|
|
|
1
|
|
|
|
|
313
|
|
17
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub setup { |
20
|
0
|
|
|
0
|
1
|
|
my(%args) = @_; |
21
|
0
|
0
|
|
|
|
|
if (exists $args{-logfile}) { |
22
|
0
|
|
|
|
|
|
$logfile = delete $args{-logfile}; |
23
|
|
|
|
|
|
|
} |
24
|
0
|
0
|
|
|
|
|
if (keys %args) { |
25
|
0
|
|
|
|
|
|
die "Unrecognized " . __PACKAGE__ . "::setup switches: " . join(", ", keys %args); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub user { |
30
|
0
|
|
|
0
|
1
|
|
my($we, $type) = @_; |
31
|
0
|
0
|
|
|
|
|
$type = "login" if !defined $type; |
32
|
0
|
0
|
|
|
|
|
my $user = (ref $we ? $we->CurrentUser : $we); |
33
|
0
|
|
|
|
|
|
my $date = scalar localtime time; |
34
|
0
|
|
0
|
|
|
|
my $host = $ENV{REMOTE_ADDR} || "unknwon"; |
35
|
0
|
|
|
|
|
|
my $line = "$0: $type user " . $user . " at $date from $host\n"; |
36
|
0
|
0
|
|
|
|
|
TRY: { |
37
|
0
|
|
|
|
|
|
last if !defined $logfile; |
38
|
0
|
0
|
|
|
|
|
last if !open(LOG, ">>$logfile"); |
39
|
0
|
|
|
|
|
|
print LOG $line; |
40
|
0
|
|
|
|
|
|
close LOG; |
41
|
0
|
|
|
|
|
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
print STDERR $line; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |