Browse Source

log use DTM_DEBUG

pull/73/head
yedf2 4 years ago
parent
commit
dba3c37e2e
  1. 4
      dtmcli/dtmimp/utils.go
  2. 2
      test/main_test.go

4
dtmcli/dtmimp/utils.go

@ -26,7 +26,7 @@ import (
// AsError wrap a panic value as an error
func AsError(x interface{}) error {
LogRedf("panic to error: '%v'", x)
LogRedf("panic wrapped to error: '%v'", x)
if e, ok := x.(error); ok {
return e
}
@ -124,7 +124,7 @@ var logger *zap.SugaredLogger = nil
func init() {
config := zap.NewProductionConfig()
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
if os.Getenv("DTM_PRODUCTION") == "" {
if os.Getenv("DTM_DEBUG") != "" {
config.Encoding = "console"
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
}

2
test/main_test.go

@ -7,6 +7,7 @@
package test
import (
"os"
"testing"
"time"
@ -19,6 +20,7 @@ import (
func TestMain(m *testing.M) {
common.MustLoadConfig()
dtmcli.SetCurrentDBType(common.DtmConfig.DB["driver"])
os.Setenv("DTM_DEBUG", "1")
dtmsvr.TransProcessedTestChan = make(chan string, 1)
dtmsvr.NowForwardDuration = 0 * time.Second
dtmsvr.CronForwardDuration = 180 * time.Second

Loading…
Cancel
Save