On Tue, 19 Jun 2001, Doug MacEachern wrote:
> On Wed, 20 Jun 2001, Stas Bekman wrote:
>
> > Can you give me an example of how would you want to use those? Why would
> > you want to have notify functions have this capability.
>
> can you give me examples of how you would want to use dumper() ?
> they would be the same reasons.
got it :)
> > Something like this?
> >
> > my $expand = sub {
> > HAS_DUMPER ?
> > map { ref $_ ? Data::Dumper::Dumper($_) : $_ } @_ :
> > @_;
> > }
> >
> > sub c_trace {
> > my $level = shift;
> > my $fh = \*STDERR; #could configure to something else
> > print $fh $colors{$level},
> > join("\n", $expand->(@_), ''), $colors{reset};
> > }
>
> looks good, but i would change the first part to:
> *expand = HAS_DUMPER ? sub { map { ... } } : sub { @_ };
can you please explain why yours is better? HAS_DUMPER is a compile time
constant, which means that if we have Data::Dumper my code resolves into:
my $expand = sub {
map { ref $_ ? Data::Dumper::Dumper($_) : $_ } @_;
}
so is $expand->(@_) resolving overhead makes it slower than aliased
expand(@_) in your version?
> > So shell we start with Apache::TestTrace for now?
>
> sounds good.
I've also sent an email to Michael Schwern asking him whether he would
like to integrate it into Test::Harness.
> do you plan to implement a $Level similar to Apache's LogLevel, so we
> have the default set to error or warning for normal builds, but people
> can turn it up for more verbose output. that would be cool.
yup, sounds cool! Will add this functionality. Just a question about
the way to change $Level. Is this how you would like it to be?
use Apache::TestTrace; # use $Level == warning
# setting hardcoded
Apache::TestTrace::level('info'); # $Level == info
# setting driven by command line args
Apache::TestTrace::level($opts{level})
if $opts{level}; # use whichever level was passed
we cannot really use the import() trick here if we want to be able to rely
on %opts.
Also we might want to raise the level only for a specific code section,
since we might want to debug only a specific code snippet:
my $old_level = Apache::TestTrace::level('debug');
...
Apache::TestTrace::level($old_level);
Another possibility is to use package's global to make the level tweaking:
{
local $Apache::TestTrace::LEVEL = 'debug';
...
}
# $Apache::TestTrace::LEVEL gets restored to the previous value
but then we will have to decide for each trace function whether to do
something or to be NOP at run-time.
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]