difference in logging mechanism: API and application(python)
        Posted  
        
            by zubin71
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by zubin71
        
        
        
        Published on 2010-04-13T15:37:40Z
        Indexed on 
            2010/04/13
            15:53 UTC
        
        
        Read the original article
        Hit count: 389
        
I am currently writing an API and an application which uses the API. I have gotten suggestions from people stating that I should perform logging using handlers in the application and use a "logger" object for logging from the API.
In light of the advice I received above, is the following implementation correct?
class test:
    def __init__(self, verbose):
        self.logger = logging.getLogger("test")
        self.logger.setLevel(verbose)
    def do_something(self):
        # do something
        self.logger.log("something")
        # by doing this i get the error message "No handlers could be found for logger "test"
The implementation i had in mind was as follows:
 #!/usr/bin/python
 """ 
 ....
 ....
 create a logger with a handler 
 ....
 ....
 """
 myobject = test()
 try:
     myobject.do_something()
 except SomeError:
     logger.log("cant do something")
Id like to get my basics strong, id be grateful for any help and suggestions for code you might recommend I look up.
Thnkx!
© Stack Overflow or respective owner