Subject: | SQL::Translator::Schema::Graph doesn't respect pre-initialization of Log::Log4perl |
SQL::Translator::Schema::Graph fails to check if Log4perl has been
initialized. I've attached a diff and a testcase to check this and only
init if it hasn't been done before. This could be much more elegant
(changing the log local level onlyt e.g.) but I think this is sufficient
for most cases and clearly better than the current behaviour
Subject: | 50_logger.t |
#!/usr/bin/perl
# vim: set ft=perl:
use strict;
use Log::Log4perl qw/:easy/;
use Log::Log4perl::Level;
BEGIN {
use Test::More do{
if ( not Log::Log4perl->can('initialized') ) {
skip_all => "Log::Log4perl too old to support initialization state"
} else {
tests => 3
}
};
}
BEGIN {
Log::Log4perl::Logger::create_custom_level("PRIVATE", "OFF");
Log::Log4perl->easy_init( $Log::Log4perl::Level::PRIORITY{PRIVATE} );
cmp_ok( $main::PRIVATE, '>', 0, "Created custom log level is sane" );
use_ok( qw/SQL::Translator::Schema::Graph/ );
}
my $log = Log::Log4perl->get_logger;
is(
$log->level, $main::PRIVATE,
'Importing SQL::Translator::Schema::Graph leaves default log level alone'
);
Subject: | sqlt_schema_graph.diff |
Index: lib/SQL/Translator/Schema/Graph.pm
===================================================================
RCS file: /cvsroot/sqlfairy/sqlfairy/lib/SQL/Translator/Schema/Graph.pm,v
retrieving revision 1.10
diff -r1.10 Graph.pm
9c9,10
< Log::Log4perl->easy_init($ERROR);
---
> Log::Log4perl->easy_init($ERROR)
> unless Log::Log4perl->can('initialized') and Log::Log4perl->initialized();