Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 8.2% on proxy.golang.org

proxy.golang.org : github.com/reiver/go-httplog

Package httplog provides logging functionality that is more geared towards existing inside of an HTTP handler. It provides 9 methods that you likely expect from a logger, which are exactly the same the ones in Go's built-in "log" package. Namely: Fatal, Fatalf, Fatalln, Panic, Panicf, Panicln, Print, Printf and Println. So, for example, you are still able to do things such as: Which should be very familiar to anyone who has used Go's built in "log" package. However, httplog also provides 26 methods (that Go's built-in "log" package does NOT have) that makes it easier to return a 2xx, 4xx or 5xx HTTP response. So, for example, you are able to do things such as: The usage of the InternalServerError method in this example (as well as any of the other 25 of the 26 methods that make it easier to return a 2xx, 4xx or 5xx HTTP response) will completely deal with sending the HTTP response over the 'http.ResponseWriter'. The other important feature is that if the 'http logger' was created with its 'dumpLogs' parameters set to 'true'. So, for example: Then in the header of the HTTP response sent with any of the 26 methods (that make it easier to return a 2xx, 4xx or 5xx HTTP response), such as InternalServerError, NotFound, Unauthorized, NotImplemented, etc, you will get the logs dumped using HTTP response headers that look like: Or, for a better example of these headers, what it would look like with other HTTP response headers is:

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/reiver/go-httplog
License: MIT
Latest release: over 7 years ago
First release: over 7 years ago
Namespace: github.com/reiver
Stars: 0 on GitHub
Forks: 1 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 1 day ago

    Loading...
    Readme
    Loading...