diff options
author | Justin Nuß <nuss.justin@gmail.com> | 2014-07-26 11:23:58 +0200 |
---|---|---|
committer | Justin Nuß <nuss.justin@gmail.com> | 2014-07-26 11:23:58 +0200 |
commit | 91480f3791f266369c343c539f8eeec245fa969a (patch) | |
tree | a03ad6062fe4b546367cdb6f9921399458d97441 /modules/middleware/logger.go | |
parent | 835e85b5ce9921ffd4d50b90b706e02685167331 (diff) | |
parent | 35c75f06a0a4f321021984830d760e67ca0ef8e5 (diff) |
Merge branch 'dev' of https://github.com/gogits/Gogs into issue/281
Conflicts:
modules/base/tool.go
Diffstat (limited to 'modules/middleware/logger.go')
-rw-r--r-- | modules/middleware/logger.go | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/modules/middleware/logger.go b/modules/middleware/logger.go deleted file mode 100644 index f918281a..00000000 --- a/modules/middleware/logger.go +++ /dev/null @@ -1,52 +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" - - "github.com/gogits/gogs/modules/setting" -) - -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) { - if setting.DisableRouterLog { - return - } - - 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) - } -} |