2014-05-20 12:17:01 +02:00
|
|
|
# File: SQLiteLoggerLayer
|
|
|
|
# Author: pragma_
|
|
|
|
#
|
|
|
|
# Purpose: PerlIO::via layer to log DBI trace messages
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2019-07-11 03:40:53 +02:00
|
|
|
use feature 'unicode_strings';
|
|
|
|
|
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) = @_;
|
|
|
|
|
|
|
|
# $path is our logger object
|
|
|
|
$$self = $path;
|
|
|
|
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) = @_;
|
|
|
|
$$self->log($buf);
|
|
|
|
return length($buf);
|
2014-05-20 12:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub CLOSE {
|
2020-02-15 23:38:32 +01:00
|
|
|
my $self = shift;
|
|
|
|
$$self->close();
|
|
|
|
return 0;
|
2014-05-20 12:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|