This is a composable HTTP logging library. It doesn’t dictate how you should log your stuff. Instead, it provides a toolkit to help roll your own logger. Use the parts you like and ignore the rest.
- It’s based around a
LogRequeststruct that contains parsed info about a HTTP request.
LogHandlermiddleware lets you log any HTTP request. You give it a function that gets a
LogRequest. The function can format and write log entries any way it likes.
- To format log entries, you can use the
CombinedLogLinefunction. It’s also easy to roll your own formatting:
LogRequestshould have all the info you need.
The hard parts of this library were extracted from the Gorilla Handlers package. This logging library is framework-agnostic and doesn’t depend on Gorilla or anything else outside the Go standard libraries.