title: TypeError: 'Logger' object is not callable
body: <p>I have tool, where some classes with inheritance used.</p>
  
  <p>This my first big OOP based tool, and I'm little bit confused with classes initialization.</p>
  
  <p>A lot of code below, to make this <strong>Q</strong> more clear.</p>
  
  <p>Short inheritance tree:</p>
  
  <pre><code>- RDSmanager(object)
      - Options(RDSmanager)
      - AutoEnv(RDSmanager)
      - UnityXMLgenerator(RDSmanager)
  </code></pre>
  
  <p>Exactly logger class is:</p>
  
  <pre><code>class Logger(object):
  
      def __init__(self, rdsmanager_localpath):
  
          """Create Logger"""
  
          self.rdsmanager_localpath = rdsmanager_localpath
  
          if not os.path.isdir(os.path.join(self.rdsmanager_localpath, 'logs')):
              os.mkdir(os.path.join(self.rdsmanager_localpath, 'logs'))
  
      def logger(self, modname):
  
          self.logger = logging.getLogger(modname)
  
          formatter = logging.Formatter('%(asctime)s  - %(filename)s[LINE:%(lineno)d] - %(name)s.%(funcName)s() - %(message)s')
  
          self.logger.setLevel(logging.DEBUG)
  
          filehandler = logging.FileHandler(os.path.join(self.rdsmanager_localpath, 'logs', 'rdsmanager.log'))
          filehandler.setLevel(logging.DEBUG)
          filehandler.setFormatter(formatter)
  
          consolehandler = logging.StreamHandler()
          consolehandler.setLevel(logging.INFO)
  
          self.logger.addHandler(filehandler)
          self.logger.addHandler(consolehandler)
  </code></pre>
  
  <p>Main script <code>RDSmanager.py</code> contain:</p>
  
  <pre><code>from lib.local.rds_services import Logger
  ...
  
  class RDSmanager(object):
      ...
  
      # path to current RDSmanager directory
      # used toi determine where files (generated XML, logs etc) c to store in
      rdsmanager_localpath = os.path.dirname(os.path.abspath(__file__))
  
      # global logger object
      logger = Logger(rdsmanager_localpath)
  </code></pre>
  
  <p>Next, I have two options - <code>-c</code> and <code>-D</code> in other class:</p>
  
  <pre><code>class Options(RDSmanager):
  
      """Main "selector" for passed options.
         For each option - appropriate Class.method() will be imported, initialized and called."""
  
      def getopts(self):
          ...
          parser = argparse.ArgumentParser()
          subparsers = parser.add_subparsers()
  
          # Unity options
          parser_unity = subparsers.add_parser('unity', help='Unity application options')
          parser_unity.set_defaults(func=self.handler_unity)
          ...
              parser_unity.add_argument('-c',
                                    '--confgen',
                                    action='store_true',dest='unity_confgen',
          ...
              parser_unity.add_argument('-D',
                                    '--deployauto',
                                    action='store_true',
                                    dest='unity_autoenv_deploy',
          ...
  
      def handler_unity(self, options_list):
  
          ...   
  
          if options_list.unity_confgen:
              self.logger.logger.info('Running Unity XML files generator.')
              from lib.unity.xml_config_generator import UnityXMLgenerator
              confgen = UnityXMLgenerator()
              # generate application's config.xml
              confgen.config_xml_generator()
              # generate XML files for each module with TAG == 'CLOUD'
              # see lib.unity.unity_services.UnityServices() docstring for details
              confgen.modules_xmls_generator()
          ...
  
          if options_list.unity_autoenv_deploy:
              self.logger.logger.info('Running developers AutoEnvironment deploy.')
              from lib.unity.autoenv.developers_auto_env import AutoEnv
              auto = AutoEnv()
              auto.deploy()
  </code></pre>
  
  <p>Next, each class run <code>logger</code> initialization, i.e.:</p>
  
  <pre><code>class UnityXMLgenerator(RDSmanager):
  
      def __init__(self):
  
          print(id(self.logger.logger))
          print(id(self.logger))
  
          # self.build_type = build_type
  
          # self.logger.logger(self.__class__.__name__)
  
          print('self.logger')
          print(self.logger)
  
          print('self.logger.logger')
          print(self.logger.logger)
  
          self.logger.logger(self.__class__.__name__)
  
          ...
  
  class AutoEnv(RDSmanager):
  
      def __init__(self):
  
          # self.build_type = build_type
  
          self.logger.logger(self.__class__.__name__)
  </code></pre>
  
  <p>When <code>-c</code> option used (i.e. - when <code>class UnityXMLgenerator(RDSmanager)</code> initialized directly from <code>class Options(RDSmanager)</code>) - all works good:</p>
  
  <blockquote>
  <pre><code>&gt; RDSmanager.py unity -c
  RDSmanager started at 23, Sep 2015 at 14:38:57
  Running Unity XML files generator.
  39816128
  52831184
  self.logger
  &lt;lib.local.rds_services.Logger object at 0x032623D0&gt;
  self.logger.logger
  &lt;bound method Logger.logger of &lt;lib.local.rds_services.Logger object at 0x032623D0&gt;&gt;
  ...
  </code></pre>
  </blockquote>
  
  <p>But - problem appears, when <code>class UnityXMLgenerator(RDSmanager)</code> called from <code>class AutoEnv(RDSmanager)</code>'s method:</p>
  
  <pre><code>def mkconfig(self):
      ...
      confgen = UnityXMLgenerator()
      ...
  </code></pre>
  
  <p>And run:</p>
  
  <blockquote>
  <pre><code>&gt; RDSmanager.py unity -D
  RDSmanager started at 23, Sep 2015 at 14:43:16
  Running developers AutoEnvironment deploy.
  Story NG-5859-developers-auto-env-build-config status checked - OK
  39011216
  52678608
  self.logger
  &lt;lib.local.rds_services.Logger object at 0x0323CFD0&gt;
  self.logger.logger
  &lt;logging.Logger object at 0x02534390&gt;
  Traceback (most recent call last):
    File "D:\Dropbox\RDS\rdsmanager_NG-1\RDSmanager.py", line 258, in &lt;module&gt;
      rds.getopts()
    File "D:\Dropbox\RDS\rdsmanager_NG-1\RDSmanager.py", line 176, in getopts
      res.func(res)
    File "D:\Dropbox\RDS\rdsmanager_NG-1\RDSmanager.py", line 228, in handler_unity
      auto.deploy()
    File "D:\Dropbox\RDS\rdsmanager_NG-1\lib\unity\autoenv\developers_auto_env.py", line 95, in deploy
      self.mkconfig()
    File "D:\Dropbox\RDS\rdsmanager_NG-1\lib\unity\autoenv\developers_auto_env.py", line 70, in mkconfig
      confgen = UnityXMLgenerator()
    File "D:\Dropbox\RDS\rdsmanager_NG-1\lib\unity\xml_config_generator.py", line 32, in __init__
      self.logger.logger(self.__class__.__name__)
  TypeError: 'Logger' object is not callable
  </code></pre>
  </blockquote>
  
  <p>Questions is:</p>
  
  <ol>
  <li>Why if I run <code>confgen = UnityXMLgenerator()</code> from <code>class Options(RDSmanager)</code> - object <code>self.logger.logger</code> is "<code>&lt;bound method Logger.logger of &lt;lib.local.rds_services.Logger object at 0x032623D0&gt;&gt;</code>" - but it's is "<code>&lt;logging.Logger object at 0x02534390&gt;</code>" - when it's initialized from <code>class RDSmanager(object)</code>'s child class class <code>AutoEnv(RDSmanager)</code> with <code>confgen = UnityXMLgenerator()</code>?</li>
  <li>What exactly means "<code>&lt;logging.Logger object at 0x02534390&gt;</code>" and "<code>&lt;bound method Logger.logger of &lt;lib.local.rds_services.Logger object at 0x032623D0&gt;&gt;</code>"?</li>
  <li>What I'm doing wrong here and how can I find solution for this issue?</li>
  </ol>