基于 `zap` 包封装。除了实现 `Go` 日志包的基本功能外,还实现了很多高级功能 本包基于`github.com/tkestack/tke/pkg/util/log`裁剪
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
522 B

2 years ago
  1. package log_test
  2. import (
  3. "cynking.com/pkg/log"
  4. "fmt"
  5. "github.com/stretchr/testify/assert"
  6. "testing"
  7. )
  8. func Test_Options_Validate(t *testing.T) {
  9. opts := &log.Options{
  10. Level: "test",
  11. Format: "test",
  12. EnableColor: true,
  13. DisableCaller: false,
  14. OutputPaths: []string{"stdout"},
  15. ErrorOutputPaths: []string{"stderr"},
  16. }
  17. errs := opts.Validate()
  18. expected := `[unrecognized level: "test" not a valid log format: "test"]`
  19. assert.Equal(t, expected, fmt.Sprintf("%s", errs))
  20. }