logging
zhangjiangqige opened this issue · comments
It would be great if this project supports logging; it helps a lot when debugging.
For now I've used github.com/gorilla/handlers and modified Run in webhooks.go to be
logSrv := handlers.LoggingHandler(os.Stdout, srv)
s := &http.Server{Addr: addr, Handler: logSrv}
return s.ListenAndServe()
Hey @neodooth so you mean just an interface on the hook you could register your own own logger with?
@joeybloggs Sorry I can not really understand what you mean by "an interface on the hook"...
What I did here is encapsulating the original "srv" with a LoggingHandler from github.com/gorilla/handlers, and it has the same interface as srv, i.e. http.Handler, so I could replace srv with logSrv in the later part of the function. Its usage is kind of similar to decorators in Python.
I'll add a configurable logger and also add a debug mode for more verbose messages.
Cool!