› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › TPS log levels
Paul,
Cloverleaf comes with Tcllib installed. You may want to explore the log package of Tcllib. It does what you are asking for.
Here are the levels available:
% package require log
1.3
% puts $::log::levels
emergency alert critical error warning notice info debug
You can select which levels to log (and where), activate and deactivate levels…
Thanks for the logging tips. I just got around to trying this out. It seems that only error messages appear. When I add the following code during the start mode of a TPS Inbound proc:
package require log
….
switch -exact — $mode {
start {
log::log info “info message”
log::log notice “notice message”
log::log warning “warning message”
log::log error “error message”
….
}
….
}
I only see the error message, even though I add enable_all_info to my thread’s Engine Log Configuration.
[tcl :err :ERR /0: tccoal:05/03/2016 14:47:52] error error message
I can see my thread name, “tccoal”. The first “error” must be coming from the log package because I see the same thing when I try this in a standalone Tcl command line.
Can we leverage the Cloverleaf EO configuration to determine which log statements get logged? Or must the log level be set programmatically?
I was also wondering about a related package in the Tcllib called logger. It seems similar to log except that one can customize a “service” name. It would really be great if this could be somehow related to the module or submodule of the EO configuration.
Hello, Paul
This has to do with the default settings in the log module:
“Note that by default all messages with levels warning down to debug are suppressed. This is done intentionally, because (we believe that) in most situations debugging output is not wanted. Most people wish to have such output only when actually debugging an application.”
So you just need to unsuppress those levels after loading the module with the following blanket command:
package require log
::log::lvSuppressLE warning 0
Once you unsuppress the levels, all your sample commands will work:
log::log info “info message”
log::log notice “notice message”
log::log warning “warning message”
log::log error “error message”
If you want to unsuppress just a particular level, then use this more limited command with the level that you want to unsuppress, for example notice
::log::lvSuppress notice 0
You pass 1 to the command to suppress, 0 to unsuppress. You have complete control; you can pick and choose as you please.
Ah, OK. So the log level configuration would be programmatic (an administrator would need to change and reload a Tcl script to change the log level). It’s not something they could configure using Engine Output Configuration like they do with their Cloverleaf modules. I really appreciate the guidance on this.
Would Cloverleaf development entertain a feature request to better integrate UPOC/TPS log level configuration with their other Cloverleaf administrative features? I’m thinking of something akin to certain Java application server models where user-written code is just another module (i.e. package) controlled by the administration console. The programmatic change technique works fine in TEST. But in PROD (where developers might not have direct access), this is important for requesting log information from a Cloverleaf administrator who may not possess the confidence to modify Tcl code (even if it’s just to change a log level).
While pursuing Levy’s tips, I stumbled across the logger package that allows us to assign a namespace-scoped module-name to the logging instance we use to issue log statements. If this library was leveraged, then conceivably this log module name could be used in the Engine Output Configuration strings as a basis for filtering UPOC/TPS log statements. These filters can be configured in Network Monitor and/or Global Monitor if it’s available.
Hi Folks,
I’ve been working to determine a sensible logging practice using the logger package that was suggested to me earlier. I’ve posted some of the practices I’ve developed in this preliminary stage to my GitHub account at
<a href="https://github.com/pglezen/tpslogger” class=”bbcode_url”>https://github.com/pglezen/tpslogger
It will evolve as I obtain more troubleshooting experience.
For those of you not familiar with GitHub, you can register for free in order to edit source code repositories and add issues. You don’t need an account to view public repositories. For more information on Git, see <a href="https://git-scm.com/” class=”bbcode_url”>https://git-scm.com/.