Skip to content

Commit

Permalink
Add new defaults for seeing logger output
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchrisadams committed Jan 17, 2025
1 parent 9501880 commit 882e238
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/carbon_txt/web/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,29 @@
"console": {
"class": "logging.StreamHandler",
"formatter": "plain_console",
# "formatter": "json_formatter",
},
"nullhandler": {
"class": "logging.NullHandler",
},
},
"loggers": {
"django_structlog": {
"handlers": ["console"],
"level": "INFO",
},
# set our default logger
"root": {
"handlers": ["console"],
"level": "INFO",
"propagate": True,
},
"django_structlog": {
"level": "INFO",
},
"httpx": {
"handlers": ["console"],
"level": "WARNING",
},
"httpcore": {
"handlers": ["console"],
"level": "INFO",
},
"carbon_txt.processors": {
"level": "DEBUG",
"carbon_txt": {
"level": "INFO",
},
},
}
Expand Down
7 changes: 7 additions & 0 deletions src/carbon_txt/web/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@

WSGI_APPLICATION = "carbon_txt.web.config.wsgi.application"
ROOT_URLCONF = "carbon_txt.web.config.urls"


# switch to using a logger better suited for production
LOGGING["handlers"]["console"] = { # type: ignore # noqa
"class": "logging.StreamHandler",
"formatter": "key_value",
}
32 changes: 32 additions & 0 deletions src/carbon_txt/web/config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,35 @@

WSGI_APPLICATION = "carbon_txt.web.config.wsgi.application"
ROOT_URLCONF = "carbon_txt.web.config.urls"

LOGGING["handlers"]["console"] = { # type: ignore # noqa
"class": "logging.StreamHandler",
# "formatter": "key_value",
"formatter": "plain_console",
# "formatter": "json_formatter",
}

LOGGING["loggers"] = { # type: ignore # noqa
"root": {
"handlers": ["console"],
# make test logs much more quiet. Set this to INFO and specific loggers
# below to DEBUG for troubleshooting
"level": "ERROR",
# "propagate": True,
},
# "django_structlog": {
# # "level": "ERROR",
# },
# "httpx": {
# # "level": "WARNING",
# },
# "httpcore": {
# # "level": "INFO",
# },
# "carbon_txt": {
# # "level": "INFO",
# },
# "test_plugin": {
# # "level": "ERROR",
# },
}
2 changes: 1 addition & 1 deletion tests/test_plugins/process_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from structlog import get_logger

logger = get_logger()
logger = get_logger("test_plugin")


plugin_name = "test_plugin"
Expand Down

0 comments on commit 882e238

Please sign in to comment.