Pass logger instance to class
        Posted  
        
            by mridang
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by mridang
        
        
        
        Published on 2010-04-08T07:16:28Z
        Indexed on 
            2010/04/08
            7:33 UTC
        
        
        Read the original article
        Hit count: 306
        
Hi Guys,
I'm using a open-source Python library in my project. This library logs a lot of information using the logging class. ...but I can't see the output or log it to file. I know that i would have to create a logger instance and add a file-handler or a console-handler to it but how can i pass this logger instance to the class? Here's the init snippet of the class that I'm going to be using.
class Periscope:
        ''' Main Periscope class'''
        def __init__(self):
                self.config = ConfigParser.SafeConfigParser({"lang": "en"})
                if is_local:
                        self.config_file = os.path.join(bd.xdg_config_home, "periscope", "config")
                        if not os.path.exists(self.config_file):
                                folder = os.path.dirname(self.config_file)
                                if not os.path.exists(folder):
                                        logging.info("Creating folder %s" %folder)
                                        os.mkdir(folder)
                                logging.info("Creating config file")
                                configfile = open(self.config_file, "w")
                                self.config.write(configfile)
                                configfile.close()
                        else:
                                #Load it
                                self.config.read(self.config_file)
                self.pluginNames = self.listExistingPlugins()
                self._preferedLanguages = None
Any help?
Thanks guys.
© Stack Overflow or respective owner