31e5edbd by MrLee.Kun

Merge pull request #2 from astaxie/develop

pull from stable
2 parents 2af0c569 f7f390df
...@@ -37,7 +37,7 @@ import ( ...@@ -37,7 +37,7 @@ import (
37 ) 37 )
38 38
39 // beego web framework version. 39 // beego web framework version.
40 const VERSION = "1.4.3" 40 const VERSION = "1.5.0"
41 41
42 type hookfunc func() error //hook function to run 42 type hookfunc func() error //hook function to run
43 var hooks []hookfunc //hook function slice to store the hookfunc 43 var hooks []hookfunc //hook function slice to store the hookfunc
...@@ -336,7 +336,7 @@ func initBeforeHttpRun() { ...@@ -336,7 +336,7 @@ func initBeforeHttpRun() {
336 // this function is for test package init 336 // this function is for test package init
337 func TestBeegoInit(apppath string) { 337 func TestBeegoInit(apppath string) {
338 AppPath = apppath 338 AppPath = apppath
339 RunMode = "test" 339 os.Setenv("BEEGO_RUNMODE", "test")
340 AppConfigPath = filepath.Join(AppPath, "conf", "app.conf") 340 AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
341 err := ParseConfig() 341 err := ParseConfig()
342 if err != nil && !os.IsNotExist(err) { 342 if err != nil && !os.IsNotExist(err) {
......
...@@ -527,7 +527,7 @@ func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader, ...@@ -527,7 +527,7 @@ func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader,
527 // } 527 // }
528 // } 528 // }
529 func (c *Controller) GetFiles(key string) ([]*multipart.FileHeader, error) { 529 func (c *Controller) GetFiles(key string) ([]*multipart.FileHeader, error) {
530 files, ok := c.Ctx.Request.MultipartForm.File["key"] 530 files, ok := c.Ctx.Request.MultipartForm.File[key]
531 if ok { 531 if ok {
532 return files, nil 532 return files, nil
533 } 533 }
......
...@@ -78,9 +78,9 @@ func Warning(v ...interface{}) { ...@@ -78,9 +78,9 @@ func Warning(v ...interface{}) {
78 BeeLogger.Warning(generateFmtStr(len(v)), v...) 78 BeeLogger.Warning(generateFmtStr(len(v)), v...)
79 } 79 }
80 80
81 // Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0. 81 // compatibility alias for Warning()
82 func Warn(v ...interface{}) { 82 func Warn(v ...interface{}) {
83 Warning(v...) 83 BeeLogger.Warn(generateFmtStr(len(v)), v...)
84 } 84 }
85 85
86 func Notice(v ...interface{}) { 86 func Notice(v ...interface{}) {
...@@ -92,9 +92,9 @@ func Informational(v ...interface{}) { ...@@ -92,9 +92,9 @@ func Informational(v ...interface{}) {
92 BeeLogger.Informational(generateFmtStr(len(v)), v...) 92 BeeLogger.Informational(generateFmtStr(len(v)), v...)
93 } 93 }
94 94
95 // Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0. 95 // compatibility alias for Warning()
96 func Info(v ...interface{}) { 96 func Info(v ...interface{}) {
97 Informational(v...) 97 BeeLogger.Info(generateFmtStr(len(v)), v...)
98 } 98 }
99 99
100 // Debug logs a message at debug level. 100 // Debug logs a message at debug level.
...@@ -103,7 +103,7 @@ func Debug(v ...interface{}) { ...@@ -103,7 +103,7 @@ func Debug(v ...interface{}) {
103 } 103 }
104 104
105 // Trace logs a message at trace level. 105 // Trace logs a message at trace level.
106 // Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0. 106 // compatibility alias for Warning()
107 func Trace(v ...interface{}) { 107 func Trace(v ...interface{}) {
108 BeeLogger.Trace(generateFmtStr(len(v)), v...) 108 BeeLogger.Trace(generateFmtStr(len(v)), v...)
109 } 109 }
......
...@@ -157,15 +157,12 @@ func (bl *BeeLogger) writerMsg(loglevel int, msg string) error { ...@@ -157,15 +157,12 @@ func (bl *BeeLogger) writerMsg(loglevel int, msg string) error {
157 lm.level = loglevel 157 lm.level = loglevel
158 if bl.enableFuncCallDepth { 158 if bl.enableFuncCallDepth {
159 _, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth) 159 _, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth)
160 if _, filename := path.Split(file); filename == "log.go" && (line == 97 || line == 83) { 160 if !ok {
161 _, file, line, ok = runtime.Caller(bl.loggerFuncCallDepth + 1) 161 file = "???"
162 } 162 line = 0
163 if ok {
164 _, filename := path.Split(file)
165 lm.msg = fmt.Sprintf("[%s:%d] %s", filename, line, msg)
166 } else {
167 lm.msg = msg
168 } 163 }
164 _, filename := path.Split(file)
165 lm.msg = fmt.Sprintf("[%s:%d] %s", filename, line, msg)
169 } else { 166 } else {
170 lm.msg = msg 167 lm.msg = msg
171 } 168 }
...@@ -295,24 +292,33 @@ func (bl *BeeLogger) Debug(format string, v ...interface{}) { ...@@ -295,24 +292,33 @@ func (bl *BeeLogger) Debug(format string, v ...interface{}) {
295 } 292 }
296 293
297 // Log WARN level message. 294 // Log WARN level message.
298 // 295 // compatibility alias for Warning()
299 // Deprecated: compatibility alias for Warning(), Will be removed in 1.5.0.
300 func (bl *BeeLogger) Warn(format string, v ...interface{}) { 296 func (bl *BeeLogger) Warn(format string, v ...interface{}) {
301 bl.Warning(format, v...) 297 if LevelWarning > bl.level {
298 return
299 }
300 msg := fmt.Sprintf("[W] "+format, v...)
301 bl.writerMsg(LevelWarning, msg)
302 } 302 }
303 303
304 // Log INFO level message. 304 // Log INFO level message.
305 // 305 // compatibility alias for Informational()
306 // Deprecated: compatibility alias for Informational(), Will be removed in 1.5.0.
307 func (bl *BeeLogger) Info(format string, v ...interface{}) { 306 func (bl *BeeLogger) Info(format string, v ...interface{}) {
308 bl.Informational(format, v...) 307 if LevelInformational > bl.level {
308 return
309 }
310 msg := fmt.Sprintf("[I] "+format, v...)
311 bl.writerMsg(LevelInformational, msg)
309 } 312 }
310 313
311 // Log TRACE level message. 314 // Log TRACE level message.
312 // 315 // compatibility alias for Debug()
313 // Deprecated: compatibility alias for Debug(), Will be removed in 1.5.0.
314 func (bl *BeeLogger) Trace(format string, v ...interface{}) { 316 func (bl *BeeLogger) Trace(format string, v ...interface{}) {
315 bl.Debug(format, v...) 317 if LevelDebug > bl.level {
318 return
319 }
320 msg := fmt.Sprintf("[D] "+format, v...)
321 bl.writerMsg(LevelDebug, msg)
316 } 322 }
317 323
318 // flush all chan data. 324 // flush all chan data.
......
...@@ -611,6 +611,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -611,6 +611,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
611 if p.enableFilter { 611 if p.enableFilter {
612 if l, ok := p.filters[pos]; ok { 612 if l, ok := p.filters[pos]; ok {
613 for _, filterR := range l { 613 for _, filterR := range l {
614 if filterR.returnOnOutput && w.started {
615 return true
616 }
614 if ok, params := filterR.ValidRouter(urlPath); ok { 617 if ok, params := filterR.ValidRouter(urlPath); ok {
615 for k, v := range params { 618 for k, v := range params {
616 context.Input.Params[k] = v 619 context.Input.Params[k] = v
......
...@@ -58,7 +58,7 @@ func serverStaticRouter(ctx *context.Context) { ...@@ -58,7 +58,7 @@ func serverStaticRouter(ctx *context.Context) {
58 finfo, err := os.Stat(file) 58 finfo, err := os.Stat(file)
59 if err != nil { 59 if err != nil {
60 if RunMode == "dev" { 60 if RunMode == "dev" {
61 Warn(err) 61 Warn("Can't find the file:", file, err)
62 } 62 }
63 http.NotFound(ctx.ResponseWriter, ctx.Request) 63 http.NotFound(ctx.ResponseWriter, ctx.Request)
64 return 64 return
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!