broadinstitute / cromwell-tools

A collection of Python clients and accessory scripts for interacting with the Cromwell
https://cromwell-tools.readthedocs.io
BSD 3-Clause "New" or "Revised" License
22 stars 9 forks source link

Duplicate logging when using CromwellAuth.from_no_authentication #67

Closed kgalens closed 4 years ago

kgalens commented 5 years ago

Using cromwell-tools 1.1.2 (python 3.7.0), I was receiving duplicate log messages after importing CromwellAuth module and calling from_no_authentication function. This seems to be happening because the warning function was called on the logging module (instead of an instance of Logger). See below on how to replicate the issue:

import logging

logger = logging.getLogger("my_module")
logger.setLevel(logging.DEBUG)

formatter = logging.Formatter(
        "[%(asctime)s %(name)s] [%(levelname)s] " +
        "[%(filename)s:%(lineno)s - %(funcName)s()] %(message)s"
)

stream = logging.StreamHandler()
stream.setFormatter(formatter)
stream.setLevel(logging.DEBUG)
logger.addHandler(stream)

logger.debug("test1")

from cromwell_tools.cromwell_auth import CromwellAuth
auth = CromwellAuth.from_no_authentication("http://localhost")

logger.debug("test2")
[2019-04-09 11:27:48,260 my_module] [DEBUG] [test-logger.py:16 - <module>()] test1
WARNING:root:You are not using any authentication with Cromwell. For security purposes, please consider adding authentication in front of your Cromwell instance!
[2019-04-09 11:27:48,547 my_module] [DEBUG] [test-logger.py:21 - <module>()] test2
DEBUG:my_module:test2
rexwangcc commented 4 years ago

closed by #68