mirror of
https://github.com/astaxie/beego.git
synced 2024-12-22 23:20:48 +00:00
Merge branch 'develop' into logger-flush-close
This commit is contained in:
commit
c71ac7431d
@ -1,6 +1,7 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- tip
|
||||
- 1.5.3
|
||||
- 1.4.3
|
||||
- 1.3.3
|
||||
@ -35,3 +36,5 @@ script:
|
||||
- go vet -x ./...
|
||||
- $HOME/gopath/bin/golint ./...
|
||||
- go test -v ./...
|
||||
notifications:
|
||||
webhooks: https://hooks.pubu.im/services/z7m9bvybl3rgtg9
|
||||
|
@ -319,7 +319,7 @@ func LoadAppConfig(adapterName, configPath string) error {
|
||||
}
|
||||
|
||||
if !utils.FileExists(absConfigPath) {
|
||||
return fmt.Errorf("the target config file: %s don't exist!", configPath)
|
||||
return fmt.Errorf("the target config file: %s don't exist", configPath)
|
||||
}
|
||||
|
||||
if absConfigPath == appConfigPath {
|
||||
|
1
error.go
1
error.go
@ -424,6 +424,7 @@ func exception(errCode string, ctx *context.Context) {
|
||||
|
||||
func executeError(err *errorInfo, ctx *context.Context, code int) {
|
||||
if err.errorType == errorTypeHandler {
|
||||
ctx.ResponseWriter.WriteHeader(code)
|
||||
err.handler(ctx.ResponseWriter, ctx.Request)
|
||||
return
|
||||
}
|
||||
|
@ -90,16 +90,15 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) (err error) {
|
||||
addr = ":https"
|
||||
}
|
||||
|
||||
config := &tls.Config{}
|
||||
if srv.TLSConfig != nil {
|
||||
*config = *srv.TLSConfig
|
||||
if srv.TLSConfig == nil {
|
||||
srv.TLSConfig = &tls.Config{}
|
||||
}
|
||||
if config.NextProtos == nil {
|
||||
config.NextProtos = []string{"http/1.1"}
|
||||
if srv.TLSConfig.NextProtos == nil {
|
||||
srv.TLSConfig.NextProtos = []string{"http/1.1"}
|
||||
}
|
||||
|
||||
config.Certificates = make([]tls.Certificate, 1)
|
||||
config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
|
||||
srv.TLSConfig.Certificates = make([]tls.Certificate, 1)
|
||||
srv.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -113,7 +112,7 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) (err error) {
|
||||
}
|
||||
|
||||
srv.tlsInnerListener = newGraceListener(l, srv)
|
||||
srv.GraceListener = tls.NewListener(srv.tlsInnerListener, config)
|
||||
srv.GraceListener = tls.NewListener(srv.tlsInnerListener, srv.TLSConfig)
|
||||
|
||||
if srv.isChild {
|
||||
process, err := os.FindProcess(os.Getppid())
|
||||
|
@ -48,7 +48,8 @@ var colors = []brush{
|
||||
// consoleWriter implements LoggerInterface and writes messages to terminal.
|
||||
type consoleWriter struct {
|
||||
lg *log.Logger
|
||||
Level int `json:"level"`
|
||||
Level int `json:"level"`
|
||||
Color bool `json:"color"`
|
||||
}
|
||||
|
||||
// NewConsole create ConsoleWriter returning as LoggerInterface.
|
||||
@ -56,6 +57,7 @@ func NewConsole() Logger {
|
||||
cw := &consoleWriter{
|
||||
lg: log.New(os.Stdout, "", 0),
|
||||
Level: LevelDebug,
|
||||
Color: true,
|
||||
}
|
||||
return cw
|
||||
}
|
||||
@ -75,7 +77,7 @@ func (c *consoleWriter) WriteMsg(when time.Time, msg string, level int) error {
|
||||
return nil
|
||||
}
|
||||
msg = formatLogTime(when) + msg
|
||||
if runtime.GOOS == "windows" {
|
||||
if runtime.GOOS == "windows" || !c.Color {
|
||||
c.lg.Println(msg)
|
||||
return nil
|
||||
}
|
||||
|
@ -42,3 +42,10 @@ func TestConsole(t *testing.T) {
|
||||
log2.SetLogger("console", `{"level":3}`)
|
||||
testConsoleCalls(log2)
|
||||
}
|
||||
|
||||
// Test console without color
|
||||
func TestConsoleNoColor(t *testing.T) {
|
||||
log := NewLogger(100)
|
||||
log.SetLogger("console", `{"color":false}`)
|
||||
testConsoleCalls(log)
|
||||
}
|
||||
|
@ -148,6 +148,10 @@ type QuerySeter interface {
|
||||
// add OFFSET value
|
||||
// same as Limit function's args[0]
|
||||
Offset(offset interface{}) QuerySeter
|
||||
// add GROUP BY expression
|
||||
// for example:
|
||||
// qs.GroupBy("id")
|
||||
GroupBy(exprs ...string) QuerySeter
|
||||
// add ORDER expression.
|
||||
// "column" means ASC, "-column" means DESC.
|
||||
// for example:
|
||||
|
@ -272,7 +272,9 @@ func SetStaticPath(url string, path string) *App {
|
||||
if !strings.HasPrefix(url, "/") {
|
||||
url = "/" + url
|
||||
}
|
||||
url = strings.TrimRight(url, "/")
|
||||
if url != "/" {
|
||||
url = strings.TrimRight(url, "/")
|
||||
}
|
||||
BConfig.WebConfig.StaticDir[url] = path
|
||||
return BeeApp
|
||||
}
|
||||
@ -282,7 +284,9 @@ func DelStaticPath(url string) *App {
|
||||
if !strings.HasPrefix(url, "/") {
|
||||
url = "/" + url
|
||||
}
|
||||
url = strings.TrimRight(url, "/")
|
||||
if url != "/" {
|
||||
url = strings.TrimRight(url, "/")
|
||||
}
|
||||
delete(BConfig.WebConfig.StaticDir, url)
|
||||
return BeeApp
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user