Re: tcllib "logger" module question
- From: Michael Schlenker <schlenk@xxxxxxxxxxxxxxxx>
- Date: Wed, 05 Apr 2006 17:43:10 +0200
Jeff Godfrey schrieb:
"Michael Schlenker" <schlenk@xxxxxxxxxxxxxxxx> wrote in messageIt would be nice to use multiple args (especially for something like
news:49i333Fol1jhU1@xxxxxxxxxxxxxxxxx
Hi Jeff,
your right..., you currently can only pass one argument to the
logproc,
but there is at least a workaround.
Define your own custom logproc and register it.
proc myLogproc {msg} {
foreach {txt obj foo} $msg {break}
# do output as you like
}
set log [logger::init foo]
${foo}::logproc debug myLogproc
${foo}::debug [list "Message" anObjectName foo]
Depending on what type of info you want to have, you can even do
tricks
with uplevel 1 to get things like:
proc myLogproc {msg} {
# get the list of the local variable in the calling context
puts [uplevel 1 [info locals]]
}
Michael,
Thanks for the quick reply / confirmation. I should have mentioned in
the original message that I had thought about doing exactly what you
mention - just passing a single arg as a list and breaking it up in
the logging proc. I was hoping that I was just missing the obvious,
but apparently not. I'll probably do exactly as you suggest.
format strings plus args), but there are some obstacles that prevent it.
1) the current api has the signature of the logproc fixed to txt instead
of args
2) the internal machinery of the logger package prefixes your call with
extra args to keep track of the original source logger of the logging
call so it would need some tinkering to adjust the code to multiple
args... (just found a bug in there..., see:
${log}::debug foo bar baz
which prints 'baz' with servicename 'bar' because, wich is wrong. Maybe
i can put in multiple arg support when fixing this...)
Michael
.
- References:
- tcllib "logger" module question
- From: Jeff Godfrey
- Re: tcllib "logger" module question
- From: Michael Schlenker
- Re: tcllib "logger" module question
- From: Jeff Godfrey
- tcllib "logger" module question
- Prev by Date: Re: sf.net and tcl/tk pages... where's the news?
- Next by Date: Re: sf.net and tcl/tk pages... where's the news?
- Previous by thread: Re: tcllib "logger" module question
- Next by thread: Re: tcllib "logger" module question
- Index(es):
Relevant Pages
|