From: Hemang L. <hl...@ci...> - 2006-04-13 03:49:53
|
Hi Andreas, The logutil proc should also set the default level to "warn" for the new service created: proc logutil {ns {level "warn"}} { set service [string trimleft $ns :] namespace eval $ns [list logger::init $service] namespace eval $ns [list logger::import -force \ -all -namespace log $service] namespace eval $ns [list log::setlevel $level] return } Thanks, Hemang. Andreas Kupries wrote: > Hi. > > Enclosed a tcl procedure I find very convenient to create a logger > service coupled directly to a specific namespace. Service name and > namespace name are identical (modulo :: for full qualification), and > the log commands are directly acessible in the the namespace. > > _________________________________________________________ > proc logutil {ns} { > set service [string trimleft $ns :] > namespace eval $ns [list logger::init $service] > namespace eval $ns [list logger::import -force \ > -all -namespace log $service] > return > } > _________________________________________________________ > > Use > namespace eval ::foo::bar::blech > logutil ::foo::bar::blech > > Right now I have this command in a mini package of its own, however I > believe that having it in logger itself would be better. Haven't found > a real good name for it yet however. So far only > > logger::initNamespace > logger::setupServiceInNamespace > ... > > Other ideas and opinions ? > > |