Tk Library Source Code

View Ticket
Login
Ticket UUID: 856280
Title: Add deletion callbacks to logger
Type: RFE Version: None
Submitter: mic42 Created on: 2003-12-08 15:55:08
Subsystem: log Assigned To: davidw
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2003-12-18 06:18:27
Resolution: Closed By: davidw
    Closed on: 2003-12-17 23:18:27
Description:
At the moment there is no (public) way to do a clean
shutdown of the logger system. If one uses a custom
logproc that opens files etc. it is not possible to
detect the correct time a logfile should be closed etc. 

So a mechanism to associate a destructor with the
logging service would be very nice to cleanup things,
without extra bookkeeping.

Either a new subcommand of ${log} or as an option to
logger::init, the procs should be called when a delete
operation is performed, walking the tree from the
children to the root of the tree.

Michael
User Comments: davidw added on 2003-12-18 06:18:27:
Logged In: YES 
user_id=240

Closing this bug after CVS commits to add the requested feature.

davidw added on 2003-12-16 22:46:56:
Logged In: YES 
user_id=240

Ok, I updated it in CVS.  I'll leave the bug open until I
update the man page and you are happy with the new behavior.

mic42 added on 2003-12-16 16:35:35:
Logged In: YES 
user_id=302287

I looked at the patch. Two comments:

1. In most extensions callbacks are executed in the global
scope via uplevel (think of bind and fileevents)
2. it would be nicer if delcmd could be a script, as
otherwise one needed interp alias to curry extra arguments
(like channel names of the logging channel to close etc.)

So perhaps change:
    variable delcallback

    logger::walk [namespace current] delete
    catch { $delcallback [namespace current] }
     namespace delete [namespace current]

to:
            variable delcallback

    logger::walk [namespace current] delete
    catch { uplevel #0 $delcallback [namespace current] }
     namespace delete [namespace current]

Otherwise it works fine.

Michael

davidw added on 2003-12-16 06:23:03:

File Added - 70679: latest.diff

davidw added on 2003-12-16 06:23:00:
Logged In: YES 
user_id=240

Try the following patch and let me know if it's what you need.

Thanks!

mic42 added on 2003-12-14 23:19:55:
Logged In: YES 
user_id=302287

Something like it, yes. Preferably bevor the namespace is
finally deleted..

davidw added on 2003-12-14 04:17:10:
Logged In: YES 
user_id=240

Good idea.  Just to be clear, you need something like:

proc foobar ......

${loggerinstance}::setdeletecallback foobar

That is then called when that logger has 'delete' called?

Attachments: