2014-05-20 12:17:01 +02:00
|
|
|
# File: SQLiteLoggerLayer
|
|
|
|
#
|
2021-06-19 06:23:34 +02:00
|
|
|
# Purpose: PerlIO::via layer to log DBI trace messages.
|
2014-05-20 12:17:01 +02:00
|
|
|
|
2017-03-05 22:33:31 +01:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2014-05-20 12:17:01 +02:00
|
|
|
package PBot::SQLiteLoggerLayer;
|
|
|
|
|
2021-06-19 06:23:34 +02:00
|
|
|
use PBot::Imports;
|
2019-07-11 03:40:53 +02:00
|
|
|
|
2020-02-08 20:04:13 +01:00
|
|
|
sub PUSHED {
|
2020-02-15 23:38:32 +01:00
|
|
|
my ($class, $mode, $fh) = @_;
|
|
|
|
my $logger;
|
|
|
|
return bless \$logger, $class;
|
2014-05-20 12:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub OPEN {
|
2020-02-15 23:38:32 +01:00
|
|
|
my ($self, $path, $mode, $fh) = @_;
|
2021-06-19 06:23:34 +02:00
|
|
|
$$self = $path; # path is our PBot::Logger object
|
2020-02-15 23:38:32 +01:00
|
|
|
return 1;
|
2014-05-20 12:17:01 +02:00
|
|
|
}
|
|
|
|
|
2020-02-08 20:04:13 +01:00
|
|
|
sub WRITE {
|
2020-02-15 23:38:32 +01:00
|
|
|
my ($self, $buf, $fh) = @_;
|
2021-06-19 06:23:34 +02:00
|
|
|
$$self->log($buf); # log message
|
2020-02-15 23:38:32 +01:00
|
|
|
return length($buf);
|
2014-05-20 12:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub CLOSE {
|
2021-06-19 06:23:34 +02:00
|
|
|
my ($self) = @_;
|
2020-02-15 23:38:32 +01:00
|
|
|
$$self->close();
|
|
|
|
return 0;
|
2014-05-20 12:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|