Commits

Miki Tebeka  committed 0553c3f

Use ctx for logging

  • Participants
  • Parent commits 8319b9a

Comments (0)

Files changed (2)

 - Templates
 - Datastore
 - Task Queues
+- Logging
 
 See SDK documentation at http://code.google.com/appengine/docs/go/gettingstarted/

File shortie/shortie.go

 	"appengine/taskqueue"
 	"fmt"
 	"http"
-	"log"
 	"os"
 	"regexp"
 	"strings"
 		return
 	}
 
+	ctx := appengine.NewContext(r)
 	var err os.Error
 	params := &homeParams{
 		User: "stranger",
 	defer func() {
 		if err != nil {
 			params.Error = err.String()
-			log.Printf("ERROR: %s\n", params.Error)
+			ctx.Errorf("%s", err)
 		}
 		homeTemplate.Execute(w, params)
 	}()
 
-	ctx := appengine.NewContext(r)
 	u := user.Current(ctx)
 
 	if u != nil {
 	if r.Method == "POST" {
 		longURL := strings.TrimSpace(r.FormValue("url"))
 		if len(longURL) == 0 {
-			params.Error = "Empty URL"
+			err = os.NewError("Empty URL")
 			return
 		}
 
 	ctx := appengine.NewContext(r)
 	path := r.FormValue("path")
 	if len(path) == 0 {
-		log.Println("Empty value for hit handler")
+		ctx.Errorf("Empty value for hit handler")
 		return
 	}
 	incHits(ctx, path)