← All challenges
easypytest-dev/pytest · v4.4

Improve default logging format

Try this bug with AI

Fix it in the original repo with an AI agent and get feedback on how you worked.

2 free rounds each week

Round mode
  • Time limit60 min
  • Token budgetup to 1M
  • Worth up to135 XP
Sign up or sign in to start

Read the sample report

From a simulated Django round

You changed code before reproducing the bug.

Run the failing test before the first edit, so you know the failure you are fixing and can tell when it is gone.

Problem statement

Currently it is:

DEFAULT_LOG_FORMAT = "%(filename)-25s %(lineno)4d %(levelname)-8s %(message)s"

I think name (module name) would be very useful here, instead of just the base filename.

(It might also be good to have the relative path there (maybe at the end), but it is usually still very long (but e.g. $VIRTUAL_ENV could be substituted therein))

Currently it would look like this:

utils.py                   114 DEBUG    (0.000) SELECT "app_url"."id", "app_url"."created", "app_url"."url" FROM "app_url" WHERE "app_url"."id" = 2; args=(2,)
multipart.py               604 DEBUG    Calling on_field_start with no data

Using DEFAULT_LOG_FORMAT = "%(levelname)-8s %(name)s:%(filename)s:%(lineno)d %(message)s" instead:

DEBUG    django.db.backends:utils.py:114 (0.000) SELECT "app_url"."id", "app_url"."created", "app_url"."url" FROM "app_url" WHERE "app_url"."id" = 2; args=(2,)
DEBUG    multipart.multipart:multipart.py:604 Calling on_field_start with no data
The environment starts at commit 2051e30b9b59 (pytest-dev/pytest 4.4), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.