Forum Discussion
Kai_Wilke
Aug 31, 2017MVP
Hi Larry,
the execution of TCL procs does indeed introduce some overhead and personally I tend to avoid TCL procedures as much as possible.
But especially for logging purposes they add so much flexibility while reducing the overall complexity of writing code that I'm still using them... 😉
Below is the syntax I'm using for logging ...
when RULE_INIT {
set debug 9
if { $debug >= 0 } then { call logger 0 "Emergency..." }
if { $debug >= 1 } then { call logger 1 "Alert..." }
if { $debug >= 2 } then { call logger 2 "Critical..." }
if { $debug >= 3 } then { call logger 3 "Error..." }
if { $debug >= 4 } then { call logger 4 "Warning..." }
if { $debug >= 5 } then { call logger 5 "Notice..." }
if { $debug >= 6 } then { call logger 6 "Information..." }
if { $debug >= 7 } then { call logger 7 "Debug..." }
if { $debug >= 8 } then { call logger 8 "Strong Debug..." }
if { $debug >= 9 } then { call logger 8 "Very Strong Debug..." }
}
proc logger { lvl msg } {
switch -exact -- $lvl {
0 {
log -noname local0.emerg "$msg"
}
1 {
log -noname local0.alert "$msg"
}
2 {
log -noname local0.crit "$msg"
}
3 {
log -noname local0.err "$msg"
}
4 {
log -noname local0.warn "$msg"
}
5 {
log -noname local0.notice "$msg"
}
6 {
log -noname local0.info "$msg"
}
default {
log -noname local0.debug "$msg"
}
}
}
Cheers, Kai