From 0db81d68a9c1b2fdb1512eb89bc796aeac11dab5 Mon Sep 17 00:00:00 2001 From: appleboy Date: Fri, 2 Feb 2024 20:05:21 +0800 Subject: [PATCH] feat: add functions to set log levels for different request statuses - Add a new function `WithDefaultLevel` to set the log level for requests with status code < 400 - Add a new function `WithClientErrorLevel` to set the log level for requests with status code between 400 and 499 - Add a new function `WithServerErrorLevel` to set the log level for requests with status code >= 500 Signed-off-by: appleboy --- options.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/options.go b/options.go index 2906586..933b11d 100644 --- a/options.go +++ b/options.go @@ -61,18 +61,21 @@ func WithWriter(s io.Writer) Option { }) } +// WithDefaultLevel set the log level used for request with status code < 400 func WithDefaultLevel(lvl zerolog.Level) Option { return optionFunc(func(c *config) { c.defaultLevel = lvl }) } +// WithClientErrorLevel set the log level used for request with status code between 400 and 499 func WithClientErrorLevel(lvl zerolog.Level) Option { return optionFunc(func(c *config) { c.clientErrorLevel = lvl }) } +// WithServerErrorLevel set the log level used for request with status code >= 500 func WithServerErrorLevel(lvl zerolog.Level) Option { return optionFunc(func(c *config) { c.serverErrorLevel = lvl