qmp-testing-suite/golang-producer-consumer/vendor/gitlab-app.eng.qops.net/reporting-framework/ripsaw-logger-golang
bel 3997f8ce6e push 2021-09-12 21:58:04 -06:00
..
Readme.md push 2021-09-12 21:58:04 -06:00
access.go push 2021-09-12 21:58:04 -06:00
doc.go push 2021-09-12 21:58:04 -06:00
logger-async.go push 2021-09-12 21:58:04 -06:00
logger-human.go push 2021-09-12 21:58:04 -06:00
logger-json.go push 2021-09-12 21:58:04 -06:00
logger-writer.go push 2021-09-12 21:58:04 -06:00
logger.go push 2021-09-12 21:58:04 -06:00
transaction.go push 2021-09-12 21:58:04 -06:00

Readme.md

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:

  1. 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.
  2. It's basically a hack to pass data from your handler to a generic access logger middleware without replacing the http.Handler interface.

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"
}