Tk Library Source Code

View Ticket
Login
Ticket UUID: 1099722
Title: bug in logger's inheritance of level
Type: Bug Version: None
Submitter: hemanglavana Created on: 2005-01-10 20:54:55
Subsystem: log Assigned To: mic42
Priority: 7 High Severity:
Status: Closed Last Modified: 2005-01-13 04:32:06
Resolution: Fixed Closed By: mic42
    Closed on: 2005-01-12 21:32:06
Description:
Hi,

I am creating two services: foo and foo::bar using the
logger command and seting the default log level to
"notice" for the foo service. This means that the
foo::bar will also have its default level set to
"notice". However the following script shows that the
debug logs are still printed for foo::bar service.

godel:93> cat foobar.tcl 
package require logger

namespace eval ::foo {

    namespace export {[a-z]*} ;# export all commands
begining with lower case.
    variable _foo             ;# array containing foo
runtime globals

    set log [logger::init foo]
    logger::import -all -namespace log foo
    log::setlevel notice
    puts "foo level = [log::currentloglevel]"

}

namespace eval ::foo::bar {

    set log [logger::init foo::bar]
    logger::import -all -namespace log foo::bar
    # It should inherit foo's level, so do not set it here
    # log::setlevel notice
    puts "foo::bar level = [log::currentloglevel]"

}

proc ::foo::x args {
    log::warn   "foo::x warn"
    log::debug  "foo::x debug"
}
proc ::foo::bar::y args {
    log::warn   "foo::bar::y warn"
    log::debug  "foo::bar::y debug"
}

::foo::x
::foo::bar::y
godel:94> tclsh foobar.tcl 
foo level = notice
foo::bar level = notice
[Mon Jan 10 15:50:32 EST 2005] [foo] [warn] 'foo::x warn'
[Mon Jan 10 15:50:32 EST 2005] [foo] [warn]
'foo::bar::y warn'
[Mon Jan 10 15:50:32 EST 2005] [foo] [debug]
'foo::bar::y debug'    <---- this should not be printed.
godel:95> 

Note that the level for foo::bar is correctly set to
"notice", however it still ends up printing debug logs.
I suspect this is bug.

Hemang.
User Comments: mic42 added on 2005-01-13 04:32:05:
Logged In: YES 
user_id=302287

Thanks for reporting this. 

It is a bug, (now fixed with version 0.5.1), as the children
only picked up level changes after their creation but did
not inherit the current level configuration of the parent.

Michael