Skip to content

Commit

Permalink
Add disable_existing_logger:False to logging config, to prevent suppr…
Browse files Browse the repository at this point in the history
…essing logging messages from loggers that haven't been explicitly declared (#1337)
  • Loading branch information
heyman committed Apr 19, 2020
1 parent 59cafb0 commit 0662204
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions locust/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def setup_logging(loglevel, logfile=None):

LOGGING_CONFIG = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"default": {
"format": "[%(asctime)s] {0}/%(levelname)s/%(name)s: %(message)s".format(HOSTNAME),
Expand Down
8 changes: 8 additions & 0 deletions locust/test/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ def test_logging_output(self):
import logging
from locust import Locust, task, constant
custom_logger = logging.getLogger("custom_logger")
class MyLocust(Locust):
wait_time = constant(2)
@task
def my_task(self):
print("running my_task")
logging.info("custom log message")
custom_logger.info("test")
""")) as file_path:
output = subprocess.check_output([
"locust",
Expand Down Expand Up @@ -75,6 +78,11 @@ def my_task(self):
"%s/INFO/root: custom log message" % socket.gethostname(),
output,
)
# check that custom message of custom_logger is also printed
self.assertIn(
"%s/INFO/custom_logger: test" % socket.gethostname(),
output,
)

def test_skip_logging(self):
with temporary_file(textwrap.dedent("""
Expand Down

0 comments on commit 0662204

Please sign in to comment.