Logging decorator

The Logging decorator takes a pointer to the log from the Logger package, from Go's standard library. Note that we are able to pass our custom InfoHandler since we chose to implement it using the io.Writer interface:

Logging(log.New(InfoHandler, "client: ", log.Ltime)),
func Logging(l *log.Logger) Decorator {
return func(c Client) Client {
return ClientFunc(func(r *http.Request) (*http.Response, error ) {
l.Printf("%s %s", r.Method, r.URL)
return c.Do(r)
})
}
}

We execute the Printf command just before running the client's Do method.