Skip to content

feat: add logging setting#147

Merged
arthur810629 merged 4 commits intohexlet-volunteers:mainfrom
DaniilShomin:feature/logging
Mar 19, 2026
Merged

feat: add logging setting#147
arthur810629 merged 4 commits intohexlet-volunteers:mainfrom
DaniilShomin:feature/logging

Conversation

@DaniilShomin
Copy link
Copy Markdown
Contributor

Добавлена настройка для вывода логов в консоль.

Copy link
Copy Markdown

@maxjamchuk maxjamchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отличная идея добавить единый конфиг логирования. Перед мержем необходимо исправить замечания с лейблами CAUTION и WARNING (disable_existing_loggers=True). Остальные комментарии — рекомендательные.

Comment thread app/settings.py Outdated
# Logging
LOGGING = {
"version": 1,
"disable_existing_loggers": True,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

"disable_existing_loggers": True — это часто ломает/глушит логи Django и сторонних библиотек (в т.ч. django.request, django.server), потому что “существующие логгеры” отключаются, если их явно не описать в конфиге.

Рекомендация: либо поставить False, либо добавить явные секции loggers для django, django.request, etc., чтобы не потерять важные сообщения/стектрейсы.

Comment thread app/settings.py
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

handler logging.StreamHandler по умолчанию пишет в stderr. В контейнерах обычно ожидают stdout. Можно явно задать stream: "ext://sys.stdout" (или оставить как есть, если в проекте принято stderr).

Comment thread app/settings.py Outdated
"disable_existing_loggers": True,
"formatters": {
"default": {
"format": "[{asctime}] #{levelname:8} {name}:{lineno}:{funcName} - {message}",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

форматтер сейчас очень “шумный” ({lineno}:{funcName}) и при DEBUG=True будет много логов. Это ок для дев-режима, но в проде обычно выбирают уровень INFO (а не WARNING), плюс отдельные правила для django.request (например, 4xx/5xx). Можно подумать над более “продуктовым” дефолтом уровня/логгеров.

Comment thread app/settings.py
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

пересмотреть disable_existing_loggers=True, чтобы не потерять системные логи Django/библиотек.

@arthur810629 arthur810629 merged commit f645d89 into hexlet-volunteers:main Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants