2014-05-20 10:17:01 +00:00
|
|
|
# File: SQLiteLoggerLayer
|
|
|
|
# Author: pragma_
|
|
|
|
#
|
|
|
|
# Purpose: PerlIO::via layer to log DBI trace messages
|
|
|
|
|
2017-03-05 21:33:31 +00: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 10:17:01 +00:00
|
|
|
package PBot::SQLiteLoggerLayer;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2019-07-10 18:40:53 -07:00
|
|
|
use feature 'unicode_strings';
|
2021-06-06 19:12:14 -07:00
|
|
|
use utf8;
|
2019-07-10 18:40:53 -07:00
|
|
|
|
2020-02-08 11:04:13 -08:00
|
|
|
sub PUSHED {
|
2020-02-15 14:38:32 -08:00
|
|
|
my ($class, $mode, $fh) = @_;
|
|
|
|
my $logger;
|
|
|
|
return bless \$logger, $class;
|
2014-05-20 10:17:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub OPEN {
|
2020-02-15 14:38:32 -08:00
|
|
|
my ($self, $path, $mode, $fh) = @_;
|
|
|
|
|
|
|
|
# $path is our logger object
|
|
|
|
$$self = $path;
|
|
|
|
return 1;
|
2014-05-20 10:17:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-08 11:04:13 -08:00
|
|
|
sub WRITE {
|
2020-02-15 14:38:32 -08:00
|
|
|
my ($self, $buf, $fh) = @_;
|
|
|
|
$$self->log($buf);
|
|
|
|
return length($buf);
|
2014-05-20 10:17:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub CLOSE {
|
2020-02-15 14:38:32 -08:00
|
|
|
my $self = shift;
|
|
|
|
$$self->close();
|
|
|
|
return 0;
|
2014-05-20 10:17:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|