Commit 31e5edbd authored by MrLee.Kun's avatar MrLee.Kun

Merge pull request #2 from astaxie/develop

pull from stable
parents 2af0c569 f7f390df
......@@ -37,7 +37,7 @@ import (
)
// beego web framework version.
const VERSION = "1.4.3"
const VERSION = "1.5.0"
type hookfunc func() error //hook function to run
var hooks []hookfunc //hook function slice to store the hookfunc
......@@ -336,7 +336,7 @@ func initBeforeHttpRun() {
// this function is for test package init
func TestBeegoInit(apppath string) {
AppPath = apppath
RunMode = "test"
os.Setenv("BEEGO_RUNMODE", "test")
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
err := ParseConfig()
if err != nil && !os.IsNotExist(err) {
......
......@@ -527,7 +527,7 @@ func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader,
// }
// }
func (c *Controller) GetFiles(key string) ([]*multipart.FileHeader, error) {
files, ok := c.Ctx.Request.MultipartForm.File["key"]
files, ok := c.Ctx.Request.MultipartForm.File[key]
if ok {
return files, nil
}
......
......@@ -78,9 +78,9 @@ func Warning(v ...interface{}) {
BeeLogger.Warning(generateFmtStr(len(v)), v...)
}
// Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0.
// compatibility alias for Warning()
func Warn(v ...interface{}) {
Warning(v...)
BeeLogger.Warn(generateFmtStr(len(v)), v...)
}
func Notice(v ...interface{}) {
......@@ -92,9 +92,9 @@ func Informational(v ...interface{}) {
BeeLogger.Informational(generateFmtStr(len(v)), v...)
}
// Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0.
// compatibility alias for Warning()
func Info(v ...interface{}) {
Informational(v...)
BeeLogger.Info(generateFmtStr(len(v)), v...)
}
// Debug logs a message at debug level.
......@@ -103,7 +103,7 @@ func Debug(v ...interface{}) {
}
// Trace logs a message at trace level.
// Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0.
// compatibility alias for Warning()
func Trace(v ...interface{}) {
BeeLogger.Trace(generateFmtStr(len(v)), v...)
}
......
......@@ -157,15 +157,12 @@ func (bl *BeeLogger) writerMsg(loglevel int, msg string) error {
lm.level = loglevel
if bl.enableFuncCallDepth {
_, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth)
if _, filename := path.Split(file); filename == "log.go" && (line == 97 || line == 83) {
_, file, line, ok = runtime.Caller(bl.loggerFuncCallDepth + 1)
}
if ok {
_, filename := path.Split(file)
lm.msg = fmt.Sprintf("[%s:%d] %s", filename, line, msg)
} else {
lm.msg = msg
if !ok {
file = "???"
line = 0
}
_, filename := path.Split(file)
lm.msg = fmt.Sprintf("[%s:%d] %s", filename, line, msg)
} else {
lm.msg = msg
}
......@@ -295,24 +292,33 @@ func (bl *BeeLogger) Debug(format string, v ...interface{}) {
}
// Log WARN level message.
//
// Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0.
// compatibility alias for Warning()
func (bl *BeeLogger) Warn(format string, v ...interface{}) {
bl.Warning(format, v...)
if LevelWarning > bl.level {
return
}
msg := fmt.Sprintf("[W] "+format, v...)
bl.writerMsg(LevelWarning, msg)
}
// Log INFO level message.
//
// Deprecated: compatibility alias for Informational(), Will be removed in 1.5.0.
// compatibility alias for Informational()
func (bl *BeeLogger) Info(format string, v ...interface{}) {
bl.Informational(format, v...)
if LevelInformational > bl.level {
return
}
msg := fmt.Sprintf("[I] "+format, v...)
bl.writerMsg(LevelInformational, msg)
}
// Log TRACE level message.
//
// Deprecated: compatibility alias for Debug(), Will be removed in 1.5.0.
// compatibility alias for Debug()
func (bl *BeeLogger) Trace(format string, v ...interface{}) {
bl.Debug(format, v...)
if LevelDebug > bl.level {
return
}
msg := fmt.Sprintf("[D] "+format, v...)
bl.writerMsg(LevelDebug, msg)
}
// flush all chan data.
......
......@@ -611,6 +611,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if p.enableFilter {
if l, ok := p.filters[pos]; ok {
for _, filterR := range l {
if filterR.returnOnOutput && w.started {
return true
}
if ok, params := filterR.ValidRouter(urlPath); ok {
for k, v := range params {
context.Input.Params[k] = v
......
......@@ -58,7 +58,7 @@ func serverStaticRouter(ctx *context.Context) {
finfo, err := os.Stat(file)
if err != nil {
if RunMode == "dev" {
Warn(err)
Warn("Can't find the file:", file, err)
}
http.NotFound(ctx.ResponseWriter, ctx.Request)
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment