root/trunk/mylogger.pm

Revision 28, 0.7 kB (checked in by jesus, 11 years ago)

comment out DBI, leave in for example

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/bin/perl
2
3 package mylogger;
4
5 #use DBI;
6 use POSIX;
7 use vars qw/$dbh $sth/;
8
9 sub log($$$) {
10     my $sender = shift;
11     my $group = shift;
12     my $message = shift;
13     chomp($message);
14
15 #    $dbh ||= DBI->connect("DBI:mysql:database=weblogs", "logger", "", { RaiseError => 0 });
16 #    warn "DBI->connect failed." unless($dbh);
17 #    if($dbh) {
18 #        $sth ||= $dbh->prepare(q{INSERT INTO logs (host, domain, timestamp, data) VALUES(?,?,?,?)});
19 #    }
20
21     my ($user, $host) = ($sender =~ /#([^#]+)#([^#]+)/);
22     my ($time) = ($message =~ /\[([^\]]+)\]/);
23     $time ||= stftime("%d/%b/%Y:%H:%M:%S %z", localtime(time));
24 #    $sth && $sth->execute($host, $group, $time, $message);
25     print STDERR "Insert($host, $group, $time, $message);\n";
26 }
27 1;
Note: See TracBrowser for help on using the browser.