[Dbix-class] ->deploy() trashes Log4perl configuration?

Adrian Corston adrian at youramigo.com
Thu May 24 03:44:12 GMT 2007


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 =3D> { data_type =3D> 'integer', =

is_auto_increment =3D> 1 });

1;


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

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

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

my $log =3D 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 =3D bless( {
'is_OFF' =3D> sub { "DUMMY" },
'is_DEBUG' =3D> sub { "DUMMY" },
'ERROR' =3D> sub { "DUMMY" },
'is_INFO' =3D> sub { "DUMMY" },
'layout' =3D> undef,
'category' =3D> '',
'DEBUG' =3D> $VAR1->{'ERROR'},
'additivity' =3D> 1,
'is_ALL' =3D> sub { "DUMMY" },
'ALL' =3D> sub { "DUMMY" },
'is_FATAL' =3D> sub { "DUMMY" },
'is_WARN' =3D> sub { "DUMMY" },
'FATAL' =3D> $VAR1->{'ERROR'},
'appender_names' =3D> [
'Screen'
],
'WARN' =3D> $VAR1->{'ERROR'},
'INFO' =3D> $VAR1->{'ERROR'},
'level' =3D> 10000,
'num_appenders' =3D> 1,
'OFF' =3D> $VAR1->{'ERROR'},
'is_ERROR' =3D> sub { "DUMMY" }
}, 'Log::Log4perl::Logger' );
[2007/05/24 11:46:10] [DEBUG] debug before
After Deploy: $VAR1 =3D bless( {
'is_OFF' =3D> sub { "DUMMY" },
'is_DEBUG' =3D> sub { "DUMMY" },
'ERROR' =3D> sub { "DUMMY" },
'is_INFO' =3D> sub { "DUMMY" },
'layout' =3D> undef,
'category' =3D> '',
'DEBUG' =3D> sub { "DUMMY" },
'additivity' =3D> 1,
'is_ALL' =3D> sub { "DUMMY" },
'ALL' =3D> $VAR1->{'DEBUG'},
'is_FATAL' =3D> sub { "DUMMY" },
'is_WARN' =3D> sub { "DUMMY" },
'FATAL' =3D> $VAR1->{'ERROR'},
'appender_names' =3D> [
'app001'
],
'WARN' =3D> $VAR1->{'DEBUG'},
'INFO' =3D> $VAR1->{'DEBUG'},
'level' =3D> 40000,
'num_appenders' =3D> 2,
'OFF' =3D> $VAR1->{'ERROR'},
'is_ERROR' =3D> sub { "DUMMY" }
}, 'Log::Log4perl::Logger' );
%

-- =

Adrian Corston
Support Engineer
YourAmigo

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070524/be0=
0705c/attachment-0001.htm


More information about the Dbix-class mailing list