github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/web/examples/logger.go (about) 1 // Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build ingore 6 7 package main 8 9 import ( 10 "log" 11 "os" 12 13 "github.com/chai2010/gopkg/web" 14 ) 15 16 func hello(val string) string { return "hello " + val } 17 18 func main() { 19 f, err := os.Create("server.log") 20 if err != nil { 21 println(err.Error()) 22 return 23 } 24 logger := log.New(f, "", log.Ldate|log.Ltime) 25 web.Get("/(.*)", hello) 26 web.SetLogger(logger) 27 web.Run("0.0.0.0:9999") 28 }