Skip to content

Commit ef4b000

Browse files
committed
refactor: use slices.Contains to simplify code
Signed-off-by: ianlv <sunlvyun@outlook.com>
1 parent 1c9cf3e commit ef4b000

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

logger/hook.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"io"
1414
"net/http"
1515
"net/smtp"
16+
"slices"
1617
"time"
1718
)
1819

@@ -93,10 +94,8 @@ func initHookByConfig(conf *viper.Viper) (hook zap.Option, err error) {
9394
}
9495

9596
return zap.Hooks(func(entry zapcore.Entry) error {
96-
for _, level := range levels {
97-
if level == entry.Level {
98-
return internalHook.call(entry)
99-
}
97+
if slices.Contains(levels, entry.Level) {
98+
return internalHook.call(entry)
10099
}
101100
return nil
102101
}), nil

0 commit comments

Comments
 (0)