Hi Jonny
Errrr. It works sometimes. See attached program, which demonstrates the
problem I have.
Or, have I done something silly?
Cheers
#!/usr/bin/env perl
use feature qw/say unicode_strings/;
use open qw(:std :utf8);
use strict;
use warnings;
use warnings qw(FATAL utf8);
use DBI;
use Log::Handler;
# ----------------
my($dsn) = 'dbi:SQLite:dbname=/tmp/demo.sqlite';
my($dbh) = DBI -> connect($dsn, '', '', {AutoCommit => 1, RaiseError => 1});
my($logger) = Log::Handler -> new;
$logger -> add
(
dbi =>
{
columns => [qw/level message/],
dbi_handle => $dbh,
persistent => 1,
table => 'log',
values => [qw/%level %message/],
}
);
$dbh -> do('drop table if exists log');
$dbh -> do(<<EOS);
create table log
(
id integer primary key autoincrement,
level varchar(9) not null,
message text not null,
timestamp timestamp not null default current_timestamp
)
EOS
my($sth) = $dbh -> prepare('insert into log (level, message) values (?, ?)');
$sth -> execute('debug', 'one');
$sth -> finish;
$logger -> log(notice => 'two');
$logger -> notice('three');
say 'Printing the data. Expect 3 lines...';
for my $row (@{$dbh -> selectall_arrayref('select * from log order by id', {Slice => {} })})
{
say join(', ', map{"$_ => '$$row{$_}'"} sort keys %$row);
}
say '-' x 50;
$sth -> finish;