Skip to content

Commit

Permalink
Add SetLogLevel to control logs output
Browse files Browse the repository at this point in the history
  • Loading branch information
xufei01 committed May 14, 2021
1 parent f7ca803 commit 05e89e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func New(opts ...Option) (*Chell, error)
func Dump(dst, src interface{}, opts ...Option) error
func DumpWithContext(ctx context.Context, dst, src interface{}, opts ...Option)
func SetDebug(v bool)
func SetLevel(level LogLevel)
func SetMaxPoolSize(size int)
func CleanUp()
```
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func New(opts ...Option) (*Chell, error)
func Dump(dst, src interface{}, opts ...Option) error
func DumpWithContext(ctx context.Context, dst, src interface{}, opts ...Option)
func SetDebug(v bool)
func SetLogLevel(level LogLevel)
func SetMaxPoolSize(size int)
func CleanUp()
```
Expand Down
14 changes: 14 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,17 @@ func SetDebug(v bool) {
logger.SetLevel(logrus.InfoLevel)
}
}

type LogLevel = logrus.Level

const (
ErrorLevel = logrus.ErrorLevel
WarnLevel = logrus.WarnLevel
InfoLevel = logrus.InfoLevel
DebugLevel = logrus.DebugLevel
)

// SetLogLevel block the logs who's level is lower
func SetLogLevel(level LogLevel) {
logger.SetLevel(level)
}

0 comments on commit 05e89e8

Please sign in to comment.