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
|
|
|
|
2021-07-11 00:00:22 +02:00
|
|
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
|
|
|
# SPDX-License-Identifier: MIT
|
2017-03-05 22:33:31 +01:00
|
|
|
|
2021-07-24 04:22:25 +02:00
|
|
|
package PBot::Core::Utils::SQLiteLoggerLayer;
|
2014-05-20 12:17:01 +02:00
|
|
|
|
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;
|