Consider the following code, mostly crafted from reading the tcl wiki and documentation:
package require logger 0.3
proc log_custom_timestamp {level txt} {
puts "[[clock format [clock seconds]]] [$level] $txt"
}
set log [logger::init main]
${log}::info "hello world"
foreach level [logger::levels] {
interp alias {} log_custom_timestamp_$level {} log_custom_timestamp $level
${log}::logproc $level log_custom_timestamp_$level
}
${log}::info "hello world"
It produces the following output:
[Mon Aug 12 16:36:58 PDT 2024] [main] [info] 'hello world'
[Mon Aug 12 16:36:58 PDT 2024] [info] hello world
Observe that the original output has the logger name main
, but my code does not produce the name.
Is it possible to access the logger name in logproc
, so that I can customize the timestamp format while preserving the logger name?