Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 23869
Status: resolved
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: willert [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.08
Fixed in: 0.09004



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();
More exhaustive testcase: now also checks the behavior if Log::Log4perl is uninitialized
#!/usr/bin/perl # vim: set ft=perl: use strict; use Log::Log4perl qw/:easy/; use Log::Log4perl::Level; # Uncomment the next line to run the test without reloading of SQLT # use Test::Without::Module qw( Module::Refresh ); BEGIN { use Test::More do{ if ( not Log::Log4perl->can('initialized') ) { skip_all => "Log::Log4perl too old to support initialization state" } else { tests => 5 } }; } BEGIN { Log::Log4perl::Logger::create_custom_level("PRIVATE", "OFF"); cmp_ok( $main::PRIVATE, '>', 0, "Created custom log level is sane" ); SKIP: { eval { require Module::Refresh }; skip "Module::Refresh not installed, can't test reloading of SQLT", 2 if $@; use_ok( qw/SQL::Translator::Schema::Graph/ ); my $sqlt_log = Log::Log4perl->get_logger( qw/SQL::Translator::Schema::Graph/ ); is( $sqlt_log->level, Log::Log4perl::Level::ERROR_INT(), 'Importing SQL::Translator::Schema::Graph sets log level if uninitialized' ); Module::Refresh->unload_module( qw{SQL/Translator/Schema/Graph.pm} ); } Log::Log4perl->easy_init( $main::PRIVATE ); # $Log::Log4perl::Level::PRIORITY{PRIVATE} ); 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' );
SQL::Translator no longer uses Log4Perl.