994 B
Executable File
994 B
Executable File
Ripsaw Logger
I'm just documenting this somewhere before I forget and it gets lost to the codebase.
Access Log
Adding custom values
Just before the access log is written, the request headers will be scanned and any header with the prefix X-Log- is parsed and its value added to the access log. This seems weird (and it is) but it happens for two reasons:
- If you want something in the access logs from the client, you can add such a header and find that sentinel value in the logs.
- It's basically a hack to pass data from your handler to a generic access logger middleware without replacing the
http.Handlerinterface.
Example
GET /something HTTP/1.1
User-Agent: dummy request header
X-Log-Some-Value: hello world
Produces an access log something like this:
{
"bytes": 0,
"duration": 6.614542,
"httpVersion": "1.1",
"method": "GET",
"statusCode": 200,
"url": "/something"
"userAgent": "dummy request header",
"someValue": "hello world"
}