List Info

Thread: basic question about logging from TT




basic question about logging from TT
user name
2006-05-24 22:10:14
Maybe a naive question here, but is there some typical
strategy
for logging from TT?

I know I can do:

 [% PERL %]
   print STDERR "message";
 [% END %]

But tedious (and presumably inefficient?)

I'm passing the Apache request object as a param, so I can
do:

 [% r.log_notice("message") %]

which is reasonsable.

But I wonder if I'm missing something else (perhaps
obvious?)


Thanks,

Mark

_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
basic question about logging from TT
user name
2006-05-24 23:54:42
What about the std(out|err) filters?

http://www.template-toolkit.org/do
cs/plain/Manual/Filters.html#stdout_options_

-- Josh

markd wrote:
> Maybe a naive question here, but is there some typical
strategy
> for logging from TT?
> 
> I know I can do:
> 
>  [% PERL %]
>    print STDERR "message";
>  [% END %]
> 
> But tedious (and presumably inefficient?)
> 
> I'm passing the Apache request object as a param, so I
can
> do:
> 
>  [% r.log_notice("message") %]
> 
> which is reasonsable.
> 
> But I wonder if I'm missing something else (perhaps
obvious?)
> 
> 
> Thanks,
> 
> Mark
> 
> _______________________________________________
> templates mailing list
> templatestemplate-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/t
emplates


_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
basic question about logging from TT
user name
2006-05-25 10:03:37
markd wrote:
> I know I can do:
> 
>  [% PERL %]
>    print STDERR "message";
>  [% END %]
> 
> But tedious (and presumably inefficient?)

I usually do something like this in a PRE_PROCESS config
file:

    [% IF debug;
         MACRO debug_msg(text)
           FILTER stderr; "  # $text\n"; END;
       ELSE;
         debug_msg = '';
       END;
    %]

I use a 'debug' flag (set in my ttree config file or in
variables passed 
in from my Perl code/Apache handle) to enable/disable
debugging en 
masse.  If debugging is on then the debug_msg() MACRO is
defined to 
print its argument to stderr (via the stderr FILTER),
otherwise it's a 
nullup.

Then in my templates I write:

    [% debug_msg("Hello World") %]

HTH
A

_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )