On 5/21/07, Zoran Vasiljevic <[EMAIL PROTECTED]> wrote:
>
> Am 21.05.2007 um 11:59 schrieb Stephen Deasey:
>
> > On 5/21/07, Zoran Vasiljevic <[EMAIL PROTECTED]> wrote:
> >>
> >> Am 20.05.2007 um 01:50 schrieb Stephen Deasey:
> >>
> >>> + 2007-05-20  Stephen Deasey  <[EMAIL PROTECTED]>
> >>> +
> >>> +     * include/ns.h:
> >>> +     * nsd/log.c (Ns_LogLevel): Add the Ns_LogLevel() function
> >>> which
> >>> returns
> >>> +     true if the given log severity level is enabled. Sometimes the
> >>> message
> >>> +     you need to log is expensive to construct, so you'd like to
> >>> construct it
> >>> +     only if it's needed.
> >>> +
> >>
> >> Doesn't
> >>
> >>     ns_logctl severity level
> >>
> >> return what you need?
> >>
> >> Welcome to lexxsrv running at /usr/local/aw/bin/nsd (pid 631)
> >> NaviServer/4.99.2 for osx built on May  5 2007 at 12:16:43
> >> CVS Tag: $Name:  $
> >> lexxsrv:nscp 1> ns_logctl severity notice
> >> 1
> >> lexxsrv:nscp 2> ns_logctl severity debug
> >> 0
> >> lexxsrv:nscp 3>
> >
> >
> > Yes.
> >
> > So you might do:
> >
> > if {[ns_logctl severity debug]} {
> >     ns_log debug "check yourself: [before_you_wreck_yourself
> > $a_huh_huh_huh_huh]"
> > }
> >
> > Otherwise the expensive function will be substituted into the log
> > message regardless of whether it actually gets logged or not. You
> > wouldn't use it all the time.
> >
> > Ns_LogLevel() is the equivalent for C code.
> >
> > (Should be called Ns_LogSeverity() ?)
>
> I do not understand. What is the purpose of your newly implemented
> feature/call when [ns_logctl severity] does already what you wanted?


Because [ns_logctl severity ?] is a Tcl API and Ns_LogLevel() is a C one?

So the above example would become:

if (Ns_LogLevel(Debug) {
    Ns_Log(Debug, "check yourself: %s", BeforeYouWreckYourself(...));
}

Saving a call to BeforeYouWreckYourself() in the (common) case where
Debug level logging is not enabled.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to