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