Skip to content

Access log vars#829

Open
nitrag wants to merge 2 commits into
emmett-framework:masterfrom
nitrag:access-log-vars
Open

Access log vars#829
nitrag wants to merge 2 commits into
emmett-framework:masterfrom
nitrag:access-log-vars

Conversation

@nitrag

@nitrag nitrag commented Mar 26, 2026

Copy link
Copy Markdown

Resolves #312

Adds the ability to implement UserAgent and custom request/response headers to the access log.

  • Add user_agent access log variable for logging the request User-Agent header
  • Add support for arbitrary request headers via %({Header-Name}i)s syntax (gunicorn-compatible)
  • Add support for arbitrary response headers via %({Header-Name}o)s syntax (gunicorn-compatible)
  • Validate access log format strings eagerly at startup to catch misconfiguration early
  • Response header capture overhead is gated behind a needs_resp_headers flag — zero cost when no %({...}o)s atoms are in the format string

@nitrag

nitrag commented Apr 2, 2026

Copy link
Copy Markdown
Author

@gi0baro ready for review, thanks

@yeongzhiwei

Copy link
Copy Markdown

hi @gi0baro , I would also love to have this feature to put it on parity with gunicorn. any progress on this MR?

@nalundgaard

Copy link
Copy Markdown

@nitrag does this address the BodyLength part of the request? It looks like that is not present in granian.

@nitrag

nitrag commented May 15, 2026

Copy link
Copy Markdown
Author

@nalundgaard I believe there was additional overhead with adding body/content length, so I removed it. I'm hoping this PR is low enough impact so it has higher chance of being merged.

@gi0baro

@gi0baro

gi0baro commented May 15, 2026

Copy link
Copy Markdown
Member

Hey all, please stop pinging me.
If I leave a PR open and don't reject it, it doesn't mean I won't merge it.

A lot happened in my personal life in the past few months – and even if this wasn't the case – give me the time to appropriately review stuff.
When I'll be able to review this, I'll do.

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.

Support User-Agent header and response size atoms in Access Log

4 participants