Stas Bekman <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] wrote:
>> Using Apache/1.3.27 (Unix) mod_gzip/1.3.26.1a mod_perl/1.27, perl
>> 5.8.0.
>> Hi,
>> I'm working with some servers which print debugging messages through
>> a
>> wrapper function that calls Apache::Log::debug, here is a simplified
>> version:
>> sub mydebug {
>>     my $msg = shift;
>>     Apache->server()->log()->debug($msg);
>> }
>> Since Apache::Log::debug inserts the file and line number of its
>> calling location into each log entry, this means that our log entries
>> all contain the same file and line number, corresponding to the
>> location of the Apache::Log::debug call inside 'mydebug'.
>> I'm trying to figure out how to get Apache::Log to use the correct
>> file and line numbers, i.e. those of the caller of our wrapper
>> function, instead. The perlfunc man page suggests that the 'goto
>> &NAME' form of 'goto' can be used to trick 'caller', but rewriting the
>> wrapper function in the following manner:
>
> If you don't care about a little slowdown (and you probably don't,
> since it's a debug), you can do:
>
> sub mydebug {
>      my $msg = shift;
>      my($filename, $line) = (caller)[1..2];
> return eval <<EOE;
> #line $line $filename
>      Apache->server()->log()->debug($msg);
> EOE
>
> }
>
> mod_perl 2.0 API allows you to explicitly path __LINE__ and __FILE__
> arguments, to the logging functions.

Thanks for the tip! We'll probably end up using something like this.

I guess there is still the question of why 'goto &NAME' doesn't work.
Is this a bug? Is it a known bug?

Frederik

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to