コード例 #1
0
ファイル: main.go プロジェクト: maverickames/helm
func main() {
	r := helm.New(fallThrough)                         // Our fallthrough route.
	r.Use(fooMiddleware, barMiddleware, helm.Static()) // add global/router level middleware to run on every route.
	r.Handle("GET", "/", root)
	r.Handle("GET", "/users", users, authMiddleware) // local/route specific middleware that only runs on this route.
	r.GET("/users/edit", root)
	r.EnableLogging(os.Stdout)
	r.Run(":8080")
}
コード例 #2
0
ファイル: main.go プロジェクト: maverickames/timber
func main() {

	t := timber.New()
	t.AddSource(&timber.Source{Formatter: "[matthew]", Writer: os.Stdout})
	t.AddLogger(&timber.Logger{Formatter: "[awesome]", Filename: "test.log"})
	t.Open()

	r := helm.New(fallThrough) // Our fallthrough route.
	r.Handle("GET", "/", root)
	r.EnableLogging(t)
	r.Run(":8080")
	//	flag.Parse()
	//	// Just doing this will write to stdout
	//	t, err := timber.New("myprogram")
	//	exitIfError(err)
	//	t.SupportColor(*useColor)
	//
	//	// Add a log to write to disk.
	//	t.WriteToDisk("mylog", "log/", 10, 4)
	//
	//	// create our own writer
	//	f, err := os.OpenFile("log/filename1", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	//	exitIfError(err)
	//	defer f.Close()
	//
	//	// Adding additional writer into the group.
	//	t.AddWriter(f)
	//
	//	// Lets go
	//	t.Open()
	//
	//	t.LogRed("Has he lost his mind?")
	//	t.LogBlue("Can he see or is he blind?")
	//	t.LogYellow("Can he walk at all")
	//	t.Log("Or if he moves will he fall?")
	//
	//	// Remove our custom writer.
	//	t.RemoveWriter(f)
	//
	//	t.Log("Is he alive or dead?")
	//	t.Log("Has he thoughts within his head?")
	//	t.Log("We'll just pass him there")
	//	t.Log("why should we even care?")
	//
	//	// Lets wrap this up and close everyting properly.
	//	t.Close()
}