|
From: Mike S. <m...@pe...> - 2006-12-26 03:01:53
|
On Fri, 22 Dec 2006, Tom Purl wrote:
> Perl version: 5.8.8
> log4perl version: 1.02
> Carp::Assert version: 0.18
> I'm trying to use both the Carp::Assert and Log4Perl libraries in the
> same Perl script. Here's how I'm using them:
>
> use warnings;
> use strict;
> use Carp;
> use Carp::Assert;
> use Log::Log4perl qw(:easy);
The problem is that both Log::Log4perl (in :easy mode) and
Carp::Assert (by default) are trying to smuggle the symbol
'DEBUG' into the namespace of the active package.
To disambiguate Log4perl's DEBUG and Carp::Assert's DEBUG, let's
rename Carp::Assert's DEBUG to 'ADEBUG':
BEGIN {
use Carp::Assert; # or: no Carp::Assert;
*ADEBUG = *DEBUG;
undef *DEBUG;
};
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG);
DEBUG "foo";
print "bar\n" if ADEBUG;
-- Mike
Mike Schilli
m...@pe...
> I tried to fix this by changing the following line:
>
> assert($foo) if DEBUG;
>
> to this:
>
> assert($foo) if Carp::Assert::DEBUG;
> ...but I got the same error.
>
> Does anyone know of a way I can fix this? I would really like to be
> able to use Log4Perl *and* assertions in my script.
>
> Thanks again!
>
> Tom Purl
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> log4perl-devel mailing list
> log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
|