|
NAMELog::Dispatch::DBI - Class for logging to database via DBI interface SYNOPSIS use Log::Dispatch::DBI;
my $log = Log::Dispatch::DBI->new(
name => 'dbi',
min_level => 'info',
datasource => 'dbi:mysql:log',
username => 'user',
password => 'password',
table => 'logging',
);
# Or, if your handle is alreaady connected
$log = Log::Dispatch::DBI->new(
name => 'dbi',
min_level => 'info',
dbh => $dbh,
);
$log->log(level => 'emergency', messsage => 'something BAD happened');
DESCRIPTIONLog::Dispatch::DBI is a subclass of Log::Dispatch::Output, which inserts logging output into relational database using DBI interface. METHODS
TABLE SCHEMAMaybe something like this for MySQL. CREATE TABLE log (
id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
level varchar(9) NOT NULL,
message text NOT NULL,
timestamp timestamp
);
For example, $log->log(level => 'info', message => 'too bad'); will execute the following SQL: INSERT INTO log (level, message) VALUES ('info', 'too bad');
If you change this behaviour, what you should do is to subclass Log::Dispatch::DBI and override "create_statement" and "log_message" method. AUTHORTatsuhiko Miyagawa <miyagawa@bulknews.net> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSOLog::Dispatch, DBI, Log::Dispatch::Config
|