1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-10 03:10:18 +00:00

in session package, add a helpful variable SLogger to help subpackage logging information

This commit is contained in:
youngsterxyf
2016-03-24 22:43:57 +08:00
parent 2362ca00b5
commit 3300db832b
4 changed files with 31 additions and 8 deletions

View File

@ -32,8 +32,11 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
"time"
)
@ -61,6 +64,8 @@ type Provider interface {
var provides = make(map[string]Provider)
var SLogger = newSessionLog(os.Stderr)
// Register makes a session provide available by the provided name.
// If Register is called twice with the same name or if driver is nil,
// it panics.
@ -296,3 +301,15 @@ func (manager *Manager) isSecure(req *http.Request) bool {
}
return true
}
// Log implement the log.Logger
type sessionLog struct {
*log.Logger
}
// NewLog set io.Writer to create a Logger for session.
func newSessionLog(out io.Writer) *sessionLog {
sl := new(sessionLog)
sl.Logger = log.New(out, "[SESSION]", 1e9)
return sl
}