Further to this, the problem arises because Glue.pm scans its configuration
/before/ setting up the logger - and, indeed, must do so, because the logging
configuration is in the config file. However, it sets up a 'lightweight' logger
to handle the case that the configuration can't be logged. We can use the same
trick in log_fatal_error():
s...@apu:~/Projects/CVSROOT$ diff /usr/share/scmbug/lib/Scmbug/Common.pm
lib/scmbug/Scmbug/Common.pm
219a220,226
> if ( ! $logger) {
> # sb 20090312: if no logger yet exists, set up a minimal one
> use Log::Log4perl qw(:easy);
> Log::Log4perl::easy_init( $WARN );
> $logger = get_logger( "Glue" );
> }
>
This replaces my earlier suggestion and is probably better.
-----Original Message-----
From: [email protected] on behalf of Simon Brooke
Sent: Thu 12/03/2009 10:31
To: [email protected]
Subject: [scmbug-users] Logger being called before initialised and
partialsolution (version 0.26.13)
When Glue.pm checks whether to autodetect product names, it calls
log_fatal_error() if the policy is set to 'auto' and the SCM is CVS or Git.
However, at this stage the logger has not been initialised and you get the
error:
Can't call method "error" on an undefined value at
/var/lib/cvs/CVSROOT/lib/scmbug/Scmbug/Common.pm line 221.
This is fairly unhelpful, as the actual error message gets lost. Obviously the
correct solution would be to ensure that the logger gets initialised before it
is called, but in the meantime I've implemented a partial workaround:
s...@apu:~/Projects/CVSROOT$ diff /usr/share/scmbug/lib/Scmbug/Common.pm
lib/scmbug/Scmbug/Common.pm
220,223c220,226
< $Log::Log4perl::caller_depth++;
< $logger->error( $error_string );
< $Log::Log4perl::caller_depth--;
<
---
> if ( $logger) {
> $Log::Log4perl::caller_depth++;
> $logger->error( $error_string );
> $Log::Log4perl::caller_depth--;
> } else {
> print STDERR $error_string;
> }
This is inelegant but it works.
Simon Brooke, Software Specialist
Cygnet Solutions Ltd
Registered office: Swan House, Darvel, Ayrshire, Scotland, KA17 0LP
Registered in Scotland No. SC158059
mail: [email protected]
www: http://www.cygnets.co.uk
tel: +44(0)1560 323444
fax: +44(0)1560 323432
_______________________________________________
scmbug-users mailing list
[email protected]
http://lists.mkgnu.net/cgi-bin/mailman/listinfo/scmbug-users
Simon Brooke, Software Specialist
Cygnet Solutions Ltd
Registered office: Swan House, Darvel, Ayrshire, Scotland, KA17 0LP
Registered in Scotland No. SC158059
mail: [email protected]
www: http://www.cygnets.co.uk
tel: +44(0)1560 323444
fax: +44(0)1560 323432
_______________________________________________
scmbug-users mailing list
[email protected]
http://lists.mkgnu.net/cgi-bin/mailman/listinfo/scmbug-users