diff --git a/beego.go b/beego.go index 9c34c9f9..cfebfbea 100644 --- a/beego.go +++ b/beego.go @@ -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) { diff --git a/controller.go b/controller.go index 9011593a..a8b9e8d3 100644 --- a/controller.go +++ b/controller.go @@ -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 } diff --git a/log.go b/log.go index 5afba8ed..7949ed96 100644 --- a/log.go +++ b/log.go @@ -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...) } diff --git a/logs/log.go b/logs/log.go index 5c94a9d8..cebbc737 100644 --- a/logs/log.go +++ b/logs/log.go @@ -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. diff --git a/router.go b/router.go index 688b227d..ca6d917a 100644 --- a/router.go +++ b/router.go @@ -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 diff --git a/staticfile.go b/staticfile.go index 5ab853a3..7c1ed98c 100644 --- a/staticfile.go +++ b/staticfile.go @@ -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