The following example code shows that Log4perl's configuration is being trashed when calling ->deploy(). The failure behaviour is demonstrated by the lack of a "debug after" debug message.

The Dumper() prints are just for further information.

I suspect that the root cause is the use of Log::Log4perl->easy_init() by SQL::Translator::Schema::Graph, but I thought I should post it here first since my example is a DBIC one.





% cat Schema.pm
package Schema;

use warnings;
use strict;
use base qw(DBIx::Class::Schema);

__PACKAGE__ -> load_classes();

1;


% cat Schema/Table.pm
package Schema::Table;
use warnings;
use strict;
use base 'DBIx::Class';

__PACKAGE__->load_components(qw(PK::Auto Core));
__PACKAGE__->table('mytable');
__PACKAGE__->add_columns(id => { data_type => 'integer', is_auto_increment => 1 });

1;


% cat deploy.pl
use Log::Log4perl;
use Schema;
use Data::Dumper;

my $schema = Schema -> connect("dbi:SQLite:trashme.db");

Log::Log4perl -> init(
{
'log4perl.rootLogger' => 'DEBUG, Screen',
'log4perl.appender.Screen' => 'Log::Log4perl::Appender::Screen',
'log4perl.appender.Screen.stderr' => '1',
'log4perl.appender.Screen.layout' => 'Log::Log4perl::Layout::PatternLayout',
'log4perl.appender.Screen.layout.ConversionPattern' => '[%d] [%p] %m%n',
});

my $log = Log::Log4perl -> get_logger();

print "Before Deploy: ", Dumper($Log::Log4perl::Logger::ROOT_LOGGER);
$log -> debug("debug before");
$schema -> deploy();
$log -> debug("debug after");
print "After Deploy: ", Dumper($Log::Log4perl::Logger::ROOT_LOGGER);


% rm trashme.db; touch trashme.db
% perl deploy.pl
Before Deploy: $VAR1 = bless( {
'is_OFF' => sub { "DUMMY" },
'is_DEBUG' => sub { "DUMMY" },
'ERROR' => sub { "DUMMY" },
'is_INFO' => sub { "DUMMY" },
'layout' => undef,
'category' => '',
'DEBUG' => $VAR1->{'ERROR'},
'additivity' => 1,
'is_ALL' => sub { "DUMMY" },
'ALL' => sub { "DUMMY" },
'is_FATAL' => sub { "DUMMY" },
'is_WARN' => sub { "DUMMY" },
'FATAL' => $VAR1->{'ERROR'},
'appender_names' => [
'Screen'
],
'WARN' => $VAR1->{'ERROR'},
'INFO' => $VAR1->{'ERROR'},
'level' => 10000,
'num_appenders' => 1,
'OFF' => $VAR1->{'ERROR'},
'is_ERROR' => sub { "DUMMY" }
}, 'Log::Log4perl::Logger' );
[2007/05/24 11:46:10] [DEBUG] debug before
After Deploy: $VAR1 = bless( {
'is_OFF' => sub { "DUMMY" },
'is_DEBUG' => sub { "DUMMY" },
'ERROR' => sub { "DUMMY" },
'is_INFO' => sub { "DUMMY" },
'layout' => undef,
'category' => '',
'DEBUG' => sub { "DUMMY" },
'additivity' => 1,
'is_ALL' => sub { "DUMMY" },
'ALL' => $VAR1->{'DEBUG'},
'is_FATAL' => sub { "DUMMY" },
'is_WARN' => sub { "DUMMY" },
'FATAL' => $VAR1->{'ERROR'},
'appender_names' => [
'app001'
],
'WARN' => $VAR1->{'DEBUG'},
'INFO' => $VAR1->{'DEBUG'},
'level' => 40000,
'num_appenders' => 2,
'OFF' => $VAR1->{'ERROR'},
'is_ERROR' => sub { "DUMMY" }
}, 'Log::Log4perl::Logger' );
%

--
Adrian Corston
Support Engineer
YourAmigo

IMPORTANT - This email message is for the sole use of the intended recipient(s) 
and may contain confidential and privileged information in which case neither 
is intended to be waived. YourAmigo retains ownership of all copyright, trade 
secrets and other intellectual property rights in the email and attachments. 
Any unauthorized review, use, disclosure or distribution is prohibited. If you 
are not the intended recipient, please notify us and remove it from your 
system. It is your responsibility to check any attachments for viruses and 
defects before opening or sending them on. YourAmigo collects personal 
information to provide and market our services. For more information about use, 
disclosure and access, see our privacy policy at http://www.youramigo.com

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/

Reply via email to