title: How to use different loggers without passing logger variable? (Python logging)
body: <p>I have multiple modules that use the same <code>utils.py</code> package. How do I make the logger in <code>utils.py</code> differ without having to pass the logger variable from the callers(i.e. ClassA or ClassB)?</p>
  
  <p>Very simple sample codes are as following. In reality, I have a lot of functions and classes in <code>utils.py</code>, and that's why I don't want to pass the <code>logger</code> variable into <code>utils.py</code>.</p>
  
  <pre><code>~/test-two-loggers$ tree .
  
  ├── main.py
  ├── configs.py
  ├── ClassA.py
  ├── ClassB.py
  └── utils.py
  
  0 directories, 5 files
  </code></pre>
  
  <p>main.py</p>
  
  <pre><code>import ClassA
  import ClassB
  
  ClassA.func()
  ClassB.func()
  </code></pre>
  
  <p>ClassA.py</p>
  
  <pre><code>import utils
  import configs
  import logging
  
  def func():
      logger = logging.getLogger("classA")
      logger.info("in ClassA")
      utils.common_func(logger)  # I want to change this line!!!!
  </code></pre>
  
  <p>ClassB.py </p>
  
  <pre><code>import utils
  import configs
  import logging
  
  def func():
      logger = logging.getLogger("classB")
      logger.info("in ClassB")
      utils.common_func(logger)  # I want to change this line!!!!
  </code></pre>
  
  <p>utils.py </p>
  
  <pre><code>def common_func(logger):  # I want to change this line!!!!
      # do a lot of things ClassA and ClassB both need to do
      logger.info("in utils - step one finished")
      # do a lot of things ClassA and ClassB both need to do
      logger.info("in utils - step two finished")
      # do a lot of things ClassA and ClassB both need to do
      logger.info("in utils - step three finished")
  </code></pre>
  
  <p>configs.py </p>
  
  <pre><code>import logging.config
  
  logging_config = {
          "version": 1, 
          "formatters": {
              "formatter_a": {
                  "format": u"[A][%(levelname)s] %(module)s.%(lineno)d: %(message)s"
              },
              "formatter_b": {
                  "format": u"[B][%(levelname)s] %(module)s.%(lineno)d: %(message)s"
              },
          },
          "handlers": {
              "console_a": {
                  "class": "logging.StreamHandler",
                  "level": "DEBUG",
                  "formatter": "formatter_a",
                  "stream": "ext://sys.stdout"
              },
              "console_b": {
                  "class": "logging.StreamHandler",
                  "level": "DEBUG",
                  "formatter": "formatter_b",
                  "stream": "ext://sys.stdout"
              },
          },
          "loggers": {
              "classA": {
                  "level": "DEBUG",
                  "handlers": ["console_a"],
                  "propagate": "no"
              },
              "classB": {
                  "level": "DEBUG",
                  "handlers": ["console_b"],
                  "propagate": "no"
              },
          },
  }
  
  logging.config.dictConfig(logging_config)
  </code></pre>
  
  <p>Result I want:</p>
  
  <pre><code>~/test-two-loggers$ python main.py 
  [A][INFO] ClassA.7: in ClassA
  [A][INFO] utils.3: in utils - step one finished
  [A][INFO] utils.5: in utils - step two finished
  [A][INFO] utils.7: in utils - step three finished
  [B][INFO] ClassB.7: in ClassB
  [B][INFO] utils.3: in utils - step one finished
  [B][INFO] utils.5: in utils - step two finished
  [B][INFO] utils.7: in utils - step three finished
  </code></pre>
  
  <p>But I want another solution other than this. I don't want to pass the <code>logger</code> variable into <code>utils</code>.</p>