diff options
author | zhsso <zhssoge@gmail.com> | 2014-04-10 14:20:01 -0400 |
---|---|---|
committer | zhsso <zhssoge@gmail.com> | 2014-04-10 14:20:01 -0400 |
commit | f3ed11d177d76bcb1850c6670c1516d25a66eb2c (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /modules/middleware/logger.go | |
parent | fde5b16332d5c4dc8246b899cd42d58b058f2bed (diff) |
mistakes
Diffstat (limited to 'modules/middleware/logger.go')
-rw-r--r-- | modules/middleware/logger.go | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/modules/middleware/logger.go b/modules/middleware/logger.go deleted file mode 100644 index fc8e1a81..00000000 --- a/modules/middleware/logger.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package middleware - -import ( - "fmt" - "log" - "net/http" - "runtime" - "time" - - "github.com/go-martini/martini" -) - -var isWindows bool - -func init() { - isWindows = runtime.GOOS == "windows" -} - -func Logger() martini.Handler { - return func(res http.ResponseWriter, req *http.Request, ctx martini.Context, log *log.Logger) { - start := time.Now() - log.Printf("Started %s %s", req.Method, req.URL.Path) - - rw := res.(martini.ResponseWriter) - ctx.Next() - - content := fmt.Sprintf("Completed %v %s in %v", rw.Status(), http.StatusText(rw.Status()), time.Since(start)) - if !isWindows { - switch rw.Status() { - case 200: - content = fmt.Sprintf("\033[1;32m%s\033[0m", content) - case 304: - content = fmt.Sprintf("\033[1;33m%s\033[0m", content) - case 404: - content = fmt.Sprintf("\033[1;31m%s\033[0m", content) - case 500: - content = fmt.Sprintf("\033[1;36m%s\033[0m", content) - } - } - log.Println(content) - } -} |