Logging
In the next few sections, we will describe a few logging packages that you may use in your code—log, logger
,and audit
. Of course these are not the only options available, but they give a good orientation in the topic. The first one—log, is the simplest one whereas the other two are more advanced.
In general, when it comes to adding log entries in the code, the question of performance impact arises, as too many calls to logging commands may significantly slow down the application. Tcl has the ability to completely ignore empty procedures (they are compiled to the no operation
instruction at the bytecode level), and both logger
and audit
are able to take advantage of this feature, by aliasing unused commands to procedures with an empty body. Therefore, disabling the logging by setting the log level to minimum will result in almost same performance as for code without any logs.
Log package
One of the oldest libraries created for logging purposes is the log
package, coming from the tcllib...