Skip to content

Commit

Permalink
测试时不输出到stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
ggaaooppeenngg committed Feb 15, 2015
1 parent 27da713 commit 5738b15
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 1 addition & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gopher

import (
"encoding/json"
"fmt"
"html/template"
"io/ioutil"
"os"
Expand Down Expand Up @@ -78,7 +77,7 @@ func configGithubAuth() {
auth.Config.LoginSuccessRedirect = Config.GithubLoginSuccessRedirect
auth.Config.CookieSecure = Config.CookieSecure
if !auth.Config.CookieSecure {
fmt.Println("注意,cookie_secure设置为false,只能在本地环境下测试")
logger.Println("注意,cookie_secure设置为false,只能在本地环境下测试")
}
githubHandler = auth.Github(Config.GithubClientId, Config.GithubClientSecret, "user")
}
Expand Down
5 changes: 2 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import (
"log"
"net/http"
"os"
"time"

"code.google.com/p/go.net/websocket"
"github.com/dchest/captcha"
"github.com/gorilla/mux"
)

var (
logger = log.New(os.Stdout, "GOPHER", log.LstdFlags)
logger = log.New(os.Stdout, "[gopher]:", log.LstdFlags)
)

func handlerFun(route Route) http.HandlerFunc {
Expand All @@ -36,7 +35,7 @@ func handlerFun(route Route) http.HandlerFunc {
if r.URL.RawQuery != "" {
url += "?" + r.URL.RawQuery
}
fmt.Println(time.Now().Format("2006-01-02 15:04:05"), url)
logger.Println(url)
if route.Permission&Everyone == Everyone {
route.HandlerFunc(handler)
}
Expand Down
10 changes: 10 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gopher

import (
"bytes"
"log"
)

func init() {
logger = log.New(new(bytes.Buffer), "", log.LstdFlags)
}

0 comments on commit 5738b15

Please sign in to comment.