From: marc spitzer on
I am trying to get logger to log to a file and found the below on
the wiki at: http://wiki.tcl.tk/6893

my question is this the corret/prefered way to do this?

A basic example of logging to a file:

package require logger
proc log_to_file {lvl txt} {
set logfile "mylog.log"
set msg "\[[clock format [clock seconds]]\] $txt"
set f [open $logfile {WRONLY CREAT APPEND}] ;# instead of "a"
fconfigure $f -encoding utf-8
puts $f $msg
close $f
}

set log [logger::init global]
foreach lvl [logger::levels] {
interp alias {} log_to_file_$lvl {} log_to_file $lvl
${log}::logproc $lvl log_to_file_$lvl
}

${log}::info "Logging to a file"

thanks,

marc
--
ms4720(a)sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
 | 
Pages: 1
Prev: Semaphores
Next: Using snack with -blocking