#structlog — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #structlog, aggregated by home.social.
-
Почему ваши логи бесполезны и как это починить за полчаса
Когда продакшен падает в три часа ночи, строка ERROR Something went wrong не помогает никому. В статье разбираем, почему привычные текстовые логи быстро превращаются в шум при реальной нагрузке, как перейти на structured logging, зачем каждому запросу нужен request_id и как настроить нормальные JSON‑логи в Python и Go без лишней инфраструктуры.
https://habr.com/ru/companies/otus/articles/1034388/
#structured_logging #структурированные_логи #JSONлоги #логирование #request_id #observability #OpenTelemetry #structlog #slog #диагностика_ошибок
-
During my work hours, and with company resources, I made a simple but useful library to get logging very easily set up for FastAPI projects, using structlog and with integration with svcs.
I think that would be quite useful for many folks, so I'm going to try to Open Source it. I expect resistance and a lot of red tape, but still I want to give it a try. Wish me luck!
-
I've written a blog post about #logging in #python (and #structlog in particular): https://www.matthewstrawbridge.com/content/2024/python-logging-basic-better-best/
-
@judy2k Your “Stupid Things I’ve Done With Pytho” talk (https://www.youtube.com/watch?v=_MDksZlA9Bo) just saved my day and helped me solve a Python testing problem I always struggeled with: Variable data (with a known format) in test results (e.g. API responses or #structlog log records).
In this case it’s been UUID trace IDs that are unique for each request but the same for all log events of that request. I create a "SomeTraceID" class that checks if "other" is a hex-form UUID and if it's the same as before. :)
-
@hynek I know you have some snippets about using #structlog with #Flask on the docs, bu do you know of a sample repo with something like "this is a sample Flask app with everything set up to show basic request information on stdout and/or a log file using structlog"? Extra points if it has configuration for #gunicorn.
-
@xahteiwi I think old style logging formatting is preferred as an optimisation. If you use f-string then the string is evaluated before the call but depending on the log config it might not be used (i.e. debug logging disabled). Whereas if you use the old style then it is never evaluated if it is thrown away
… but better still, use #structlog 😀
-
As promised, #structlog 22.3.0 is out with two bug fixes relating native loggers and string interpolation:
https://github.com/hynek/structlog/releases/tag/22.3.0 #python #logging -
#structlog provides structured logging for #Python.
structlog implements standard timestamped, leveled message logging, but adds support for including key-value pairs within log messages. structlog sends all log messages through a set of processors, which can be used for timestamping and printing annotated tracebacks. structlog supports many output formats, including colour-coded plaintext, JSON, etc.
Website 🔗️: https://www.structlog.org/
-
🔖 Logging Rethought: The Current State Of Logging (Markus Holtermann) https://markusholtermann.eu/2019/04/logging-rethought/
#python #logging #structlog #django #security