Browse Source

discard logging in webgo framework.

This creates a logger with output to a /dev/null equivalent. You still pay
the price for formatting and copying, but there will be no IO or write
syscalls caused by logging.

refs #253
Ingo Oeser 12 years ago
parent
commit
675aee36f1
1 changed files with 2 additions and 3 deletions
  1. 2 3
      webgo/src/hello/hello.go

+ 2 - 3
webgo/src/hello/hello.go

@@ -3,8 +3,8 @@ package main
 import (
 	"encoding/json"
 	"github.com/hoisie/web"
+	"io/ioutil"
 	"log"
-	"os"
 	"runtime"
 )
 
@@ -19,8 +19,7 @@ func hello(val string) string {
 }
 
 func main() {
-	f, _ := os.Create("server.log")
-	logger := log.New(f, "", log.Ldate|log.Ltime)
+	logger := log.New(ioutil.Discard, "", log.Ldate|log.Ltime)
 	runtime.GOMAXPROCS(runtime.NumCPU())
 	web.Get("/(.*)", hello)
 	web.SetLogger(logger)