Documentation ¶
Overview ¶
Package whgls provides webhelp tools that use grossness enabled by the github.com/jtolds/gls package. No other webhelp packages use github.com/jtolds/gls.
The predominant use case for github.com/jtolds/gls is to attach a current request's contextual information to all log lines kicked off by the request.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bind ¶
Bind will make sure that Load works from any callstacks kicked off by this handler, via the magic of github.com/jtolds/gls. It is worthwhile to call Bind at the base of your handler stack and again after attaching any useful values you might want to include in logs to the request context.
func Load ¶
Load will return the *http.Request bound to the current call stack by a Bind handler further up the stack.
func SetLogOutput ¶
SetLogOutput will configure the standard library's logger to use the provided logger that requires a context, such as AppEngine's loggers. This requires that the handler was wrapped with Bind. Note that this will cause all log messages without a context to be silently swallowed!
If whmon.RequestIds was in the handler callchain prior to Bind, this logger will also attach the Request ID to all log lines.
The benefit of this is that the standard library's logger (or some other logger that doesn't use contexts) can now be used naturally on a platform that requires contexts (like App Engine).
App Engine Example:
import ( "net/http" "gopkg.in/webhelp.v1/whgls" "google.golang.org/appengine/log" ) var ( handler = ... ) func init() { whgls.SetLogOutput(log.Infof) http.Handle("/", whmon.RequestIds(whgls.Bind(handler))) }
Types ¶
This section is empty.