You are viewing a plain text version of this content. The canonical link for it is here.
Posted to websh-dev@tcl.apache.org by Ronnie Brunner <ro...@netcetera.ch> on 2004/02/25 23:29:34 UTC

Logging in web::finalizer

Hi Websh hackers

I just tried to figure out, why logging in web::finalizer (mod_websh)
doesn't work. The answer is simple: there is a proc
web::ap::perReqInit and a proc web::ap::ReqCleanup in mod_websh that
reset some stuff for different requests. As it is now,
web::ap::perReqCleanup deletes all log destinations and log filters
this is to prevent that subsequent requests don't create multiple
destinations and filters (seems to make sense). -> In web::finalizer
there are no filters and destinations anymore (because this is always
called after the request has long finished (i.e. also after
web::ap::reqCleanup)

Now I've got some solutions and I'd like to here some comments about
which one to implement:

1. do nothing and tell everyone who has that problem to repeat the
needed web::logdest and web::logfilter commands in web::finalizer
(draw back: not really that transparent)

2. also do nothing and tell people to overwrite web::ap::perReqCleanup
(draw back: not too transparent either)  

3. put [web::logdest delete] and [web::logfilter delete] in
web::ap::perReqInit instead of web::ap::perReqCleanup
(draw back: only setting log destinations and filters in
web::initializer will not work. But then, that doesn't work either
currently ;-)

4. remove the [web::logdest delete] and [web::logfilter delete] from
web::ap::perReqCleanup and change the implementation of web::logdest
and web::logfilter so that subsequent calls with the same arguments
will not create a new logdest or logfilter respectively.
The clear advantage would be that you can define your logging stuff in
web::initializer, but you also don't have problems if you define them
in your per request code. In addition, there is no need to delete them
after a request has finished -> they will still be available in
web::finalizer
(draw back: more work than the others)


All in all I tend to favor the last approach, but it's more work and a
bigger change. Is compatibility an issue? Does anyone see a porblem?

Any comments?

Thx
Ronnie
----------------------------------------------------------------------
Ronnie Brunner                             ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-dev-help@tcl.apache.org


Re: Logging in web::finalizer

Posted by "David N. Welton" <da...@dedasys.com>.
Ronnie Brunner <ro...@netcetera.ch> writes:

> 4. remove the [web::logdest delete] and [web::logfilter delete] from
> web::ap::perReqCleanup and change the implementation of web::logdest
> and web::logfilter so that subsequent calls with the same arguments
> will not create a new logdest or logfilter respectively.  The clear
> advantage would be that you can define your logging stuff in
> web::initializer, but you also don't have problems if you define
> them in your per request code. In addition, there is no need to
> delete them after a request has finished -> they will still be
> available in web::finalizer (draw back: more work than the others)

> All in all I tend to favor the last approach, but it's more work and
> a bigger change. Is compatibility an issue? Does anyone see a
> porblem?

I agree that it seems like the most correct way of doing things.  Not
having any websh code in production, I can't comment on compatibility
issues though:-)

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-dev-help@tcl.apache.org


Re: Logging in web::finalizer

Posted by Ulrich Schöbel <us...@aladyn.de>.
Am Freitag, 27. Februar 2004 10:47 schrieb Ronnie Brunner:
> > My tests worked mostly ;-) I did notice that when interpreters are
> > cleaned up because the script is renewed, some log messages don't
> > appear in the log file, but in the code I see (thanks to fprintf ;-)
> > that the logging is called. Might be something with multiple handles
> > on the same log file and flushing or something. I'll check on that.
> >
> > > I'm clearly in favour of solution 4, but i'm afraid this alone won't
> > > fix the bug.
> >
> > Yep, seems to be the way to go (in addtion to solving the rest of the
> > problem).
>
> Have you tried the "-unbuffered" for your logdest (i.e. the file you
> log to)? I got all the messages when I switched output to unbuffered.

Works for logdest ... file... but not for logdest ... apache.

Best regards

Ulrich

>
> The problem seems to be that interpreters are buffering and they have
> their own handle on the log file -> they overwrite each other if
> channels are not flushed, even in a non-multithreaded environment.
>
> Can you please check if you get all messages? Please note that it is
> also not very transparent if you have more than one child (i.e. apache
> processes) serving requests. It's kind of difficult to manually follow
> if you have all the expected messages...
>
> Regards
> Ronnie
> ----------------------------------------------------------------------
> Ronnie Brunner                             ronnie.brunner@netcetera.ch
> Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
> For additional commands, e-mail: websh-dev-help@tcl.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-dev-help@tcl.apache.org


Re: Logging in web::finalizer

Posted by Ronnie Brunner <ro...@netcetera.ch>.
> My tests worked mostly ;-) I did notice that when interpreters are
> cleaned up because the script is renewed, some log messages don't
> appear in the log file, but in the code I see (thanks to fprintf ;-)
> that the logging is called. Might be something with multiple handles
> on the same log file and flushing or something. I'll check on that.
> 
> > I'm clearly in favour of solution 4, but i'm afraid this alone won't
> > fix the bug.
> 
> Yep, seems to be the way to go (in addtion to solving the rest of the
> problem).

Have you tried the "-unbuffered" for your logdest (i.e. the file you
log to)? I got all the messages when I switched output to unbuffered.

The problem seems to be that interpreters are buffering and they have
their own handle on the log file -> they overwrite each other if
channels are not flushed, even in a non-multithreaded environment.

Can you please check if you get all messages? Please note that it is
also not very transparent if you have more than one child (i.e. apache
processes) serving requests. It's kind of difficult to manually follow
if you have all the expected messages...

Regards
Ronnie
----------------------------------------------------------------------
Ronnie Brunner                             ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-dev-help@tcl.apache.org


Re: Logging in web::finalizer

Posted by Ronnie Brunner <ro...@netcetera.ch>.
Hi Ulrich

> as you can see from the short example I mailed you, I redefined the
> web::ap::perReqCleanup proc to do nothing. This does allow me to
> define the log destination and filters in the initializer, but it does _not_
> enable logging in the finalizer. It's obviously not enough to move/remove
> this proc.

My tests worked mostly ;-) I did notice that when interpreters are
cleaned up because the script is renewed, some log messages don't
appear in the log file, but in the code I see (thanks to fprintf ;-)
that the logging is called. Might be something with multiple handles
on the same log file and flushing or something. I'll check on that.

> I'm clearly in favour of solution 4, but i'm afraid this alone won't
> fix the bug.

Yep, seems to be the way to go (in addtion to solving the rest of the
problem).

Regards
Ronnie
----------------------------------------------------------------------
Ronnie Brunner                             ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75

---------------------------------------------------------------------
To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-dev-help@tcl.apache.org


Re: Logging in web::finalizer

Posted by Ulrich Schöbel <us...@aladyn.de>.
Am Mittwoch, 25. Februar 2004 23:29 schrieb Ronnie Brunner:
> Hi Websh hackers
>
> I just tried to figure out, why logging in web::finalizer (mod_websh)
> doesn't work. The answer is simple: there is a proc
> web::ap::perReqInit and a proc web::ap::ReqCleanup in mod_websh that
> reset some stuff for different requests. As it is now,
> web::ap::perReqCleanup deletes all log destinations and log filters
> this is to prevent that subsequent requests don't create multiple
> destinations and filters (seems to make sense). -> In web::finalizer
> there are no filters and destinations anymore (because this is always
> called after the request has long finished (i.e. also after
> web::ap::reqCleanup)

Hi Ronnie,

as you can see from the short example I mailed you, I redefined the
web::ap::perReqCleanup proc to do nothing. This does allow me to
define the log destination and filters in the initializer, but it does _not_
enable logging in the finalizer. It's obviously not enough to move/remove
this proc.

I'm clearly in favour of solution 4, but i'm afraid this alone won't fix the 
bug.

Best regards

Ulrich

>
> Now I've got some solutions and I'd like to here some comments about
> which one to implement:
>
> 1. do nothing and tell everyone who has that problem to repeat the
> needed web::logdest and web::logfilter commands in web::finalizer
> (draw back: not really that transparent)
>
> 2. also do nothing and tell people to overwrite web::ap::perReqCleanup
> (draw back: not too transparent either)
>
> 3. put [web::logdest delete] and [web::logfilter delete] in
> web::ap::perReqInit instead of web::ap::perReqCleanup
> (draw back: only setting log destinations and filters in
> web::initializer will not work. But then, that doesn't work either
> currently ;-)
>
> 4. remove the [web::logdest delete] and [web::logfilter delete] from
> web::ap::perReqCleanup and change the implementation of web::logdest
> and web::logfilter so that subsequent calls with the same arguments
> will not create a new logdest or logfilter respectively.
> The clear advantage would be that you can define your logging stuff in
> web::initializer, but you also don't have problems if you define them
> in your per request code. In addition, there is no need to delete them
> after a request has finished -> they will still be available in
> web::finalizer
> (draw back: more work than the others)
>
>
> All in all I tend to favor the last approach, but it's more work and a
> bigger change. Is compatibility an issue? Does anyone see a porblem?
>
> Any comments?
>
> Thx
> Ronnie
> ----------------------------------------------------------------------
> Ronnie Brunner                             ronnie.brunner@netcetera.ch
> Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
> For additional commands, e-mail: websh-dev-help@tcl.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: websh-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-dev-help@tcl.apache.org