Merge pull request #5227 from Pulkit07/issue5214
logging: improve default logging format (issue5214)
This commit is contained in:
commit
ed2b715f4c
1
AUTHORS
1
AUTHORS
|
@ -194,6 +194,7 @@ Paweł Adamczak
|
|||
Pedro Algarvio
|
||||
Pieter Mulder
|
||||
Piotr Banaszkiewicz
|
||||
Pulkit Goyal
|
||||
Punyashloka Biswal
|
||||
Quentin Pradet
|
||||
Ralf Schmitt
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
The default logging format has been changed to improve readability. Here is an
|
||||
example of a previous logging message::
|
||||
|
||||
test_log_cli_enabled_disabled.py 3 CRITICAL critical message logged by test
|
||||
|
||||
This has now become::
|
||||
|
||||
CRITICAL root:test_log_cli_enabled_disabled.py:3 critical message logged by test
|
||||
|
||||
The formatting can be changed through the `log_format <https://docs.pytest.org/en/latest/reference.html#confval-log_format>`__ configuration option.
|
|
@ -15,7 +15,7 @@ from _pytest.compat import dummy_context_manager
|
|||
from _pytest.config import create_terminal_writer
|
||||
from _pytest.pathlib import Path
|
||||
|
||||
DEFAULT_LOG_FORMAT = "%(filename)-25s %(lineno)4d %(levelname)-8s %(message)s"
|
||||
DEFAULT_LOG_FORMAT = "%(levelname)-8s %(name)s:%(filename)s:%(lineno)d %(message)s"
|
||||
DEFAULT_LOG_DATE_FORMAT = "%H:%M:%S"
|
||||
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ def test_log_cli_enabled_disabled(testdir, enabled):
|
|||
[
|
||||
"test_log_cli_enabled_disabled.py::test_log_cli ",
|
||||
"*-- live log call --*",
|
||||
"test_log_cli_enabled_disabled.py* CRITICAL critical message logged by test",
|
||||
"CRITICAL *test_log_cli_enabled_disabled.py* critical message logged by test",
|
||||
"PASSED*",
|
||||
]
|
||||
)
|
||||
|
@ -282,7 +282,7 @@ def test_log_cli_default_level(testdir):
|
|||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"test_log_cli_default_level.py::test_log_cli ",
|
||||
"test_log_cli_default_level.py*WARNING message will be shown*",
|
||||
"WARNING*test_log_cli_default_level.py* message will be shown*",
|
||||
]
|
||||
)
|
||||
assert "INFO message won't be shown" not in result.stdout.str()
|
||||
|
@ -523,7 +523,7 @@ def test_sections_single_new_line_after_test_outcome(testdir, request):
|
|||
)
|
||||
assert (
|
||||
re.search(
|
||||
r"(.+)live log teardown(.+)\n(.+)WARNING(.+)\n(.+)WARNING(.+)",
|
||||
r"(.+)live log teardown(.+)\nWARNING(.+)\nWARNING(.+)",
|
||||
result.stdout.str(),
|
||||
re.MULTILINE,
|
||||
)
|
||||
|
@ -531,7 +531,7 @@ def test_sections_single_new_line_after_test_outcome(testdir, request):
|
|||
)
|
||||
assert (
|
||||
re.search(
|
||||
r"(.+)live log finish(.+)\n(.+)WARNING(.+)\n(.+)WARNING(.+)",
|
||||
r"(.+)live log finish(.+)\nWARNING(.+)\nWARNING(.+)",
|
||||
result.stdout.str(),
|
||||
re.MULTILINE,
|
||||
)
|
||||
|
@ -565,7 +565,7 @@ def test_log_cli_level(testdir):
|
|||
# fnmatch_lines does an assertion internally
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"test_log_cli_level.py*This log message will be shown",
|
||||
"*test_log_cli_level.py*This log message will be shown",
|
||||
"PASSED", # 'PASSED' on its own line because the log message prints a new line
|
||||
]
|
||||
)
|
||||
|
@ -579,7 +579,7 @@ def test_log_cli_level(testdir):
|
|||
# fnmatch_lines does an assertion internally
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"test_log_cli_level.py* This log message will be shown",
|
||||
"*test_log_cli_level.py* This log message will be shown",
|
||||
"PASSED", # 'PASSED' on its own line because the log message prints a new line
|
||||
]
|
||||
)
|
||||
|
@ -615,7 +615,7 @@ def test_log_cli_ini_level(testdir):
|
|||
# fnmatch_lines does an assertion internally
|
||||
result.stdout.fnmatch_lines(
|
||||
[
|
||||
"test_log_cli_ini_level.py* This log message will be shown",
|
||||
"*test_log_cli_ini_level.py* This log message will be shown",
|
||||
"PASSED", # 'PASSED' on its own line because the log message prints a new line
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue