1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 01:57:02 +00:00

More metrics, better logging

This commit is contained in:
James Hillyerd
2012-10-24 12:40:17 -07:00
parent 606fb124a6
commit 81bb394755
6 changed files with 85 additions and 34 deletions

View File

@@ -1,6 +1,7 @@
package web
import (
"fmt"
"github.com/jhillyerd/inbucket/log"
"html/template"
"io"
@@ -31,11 +32,11 @@ func MailboxList(w http.ResponseWriter, req *http.Request, ctx *Context) (err er
mb, err := ctx.DataStore.MailboxFor(name)
if err != nil {
return err
return fmt.Errorf("Failed to get mailbox for %v: %v", name, err)
}
messages, err := mb.GetMessages()
if err != nil {
return err
return fmt.Errorf("Failed to get messages for %v: %v", name, err)
}
log.Trace("Got %v messsages", len(messages))

View File

@@ -83,6 +83,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Trace("Web: %v %v %v %v", req.RemoteAddr, req.Proto, req.Method, req.RequestURI)
err = h(buf, req, ctx)
if err != nil {
log.Error("Error handling %v: %v", req.RequestURI, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}