🚀 Consistent way of logging and fix middleware log format #2432 (#2444)

- change log patter
pull/2445/head
RW 2023-05-01 18:52:30 +02:00 committed by GitHub
parent a59d9bac59
commit 3a7dbd0b48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 15 deletions

View File

@ -102,11 +102,11 @@ func configDefault(config ...Config) Config {
// Set default values
if cfg.Store != nil {
log.Printf("[CACHE] - [Warning] Store is deprecated, please use Storage\n")
log.Printf("[Warning] - [CACHE] Store is deprecated, please use Storage\n")
cfg.Storage = cfg.Store
}
if cfg.Key != nil {
log.Printf("[CACHE] - [Warning] Key is deprecated, please use KeyGenerator\n")
log.Printf("[Warning] - [CACHE] Key is deprecated, please use KeyGenerator\n")
cfg.KeyGenerator = cfg.Key
}
if cfg.Next == nil {

View File

@ -98,7 +98,7 @@ func New(config ...Config) fiber.Handler {
// Warning logs if both AllowOrigins and AllowOriginsFunc are set
if cfg.AllowOrigins != ConfigDefault.AllowOrigins && cfg.AllowOriginsFunc != nil {
log.Printf("[CORS] - [Warning] Both 'AllowOrigins' and 'AllowOriginsFunc' have been defined.\n")
log.Printf("[Warning] - [CORS] Both 'AllowOrigins' and 'AllowOriginsFunc' have been defined.\n")
}
// Convert string to slice

View File

@ -132,15 +132,15 @@ func configDefault(config ...Config) Config {
// Set default values
if cfg.TokenLookup != "" {
log.Printf("[CSRF] - [Warning] TokenLookup is deprecated, please use KeyLookup\n")
log.Printf("[Warning] - [CSRF] TokenLookup is deprecated, please use KeyLookup\n")
cfg.KeyLookup = cfg.TokenLookup
}
if int(cfg.CookieExpires.Seconds()) > 0 {
log.Printf("[CSRF] - [Warning] CookieExpires is deprecated, please use Expiration\n")
log.Printf("[Warning] - [CSRF] CookieExpires is deprecated, please use Expiration\n")
cfg.Expiration = cfg.CookieExpires
}
if cfg.Cookie != nil {
log.Printf("[CSRF] - [Warning] Cookie is deprecated, please use Cookie* related fields\n")
log.Printf("[Warning] - [CSRF] Cookie is deprecated, please use Cookie* related fields\n")
if cfg.Cookie.Name != "" {
cfg.CookieName = cfg.Cookie.Name
}

View File

@ -92,7 +92,7 @@ func New(config ...Config) fiber.Handler {
}
defer func() {
if err := cfg.Lock.Unlock(key); err != nil {
log.Printf("[IDEMPOTENCY] - [Error] failed to unlock key %q: %v", key, err)
log.Printf("[Error] - [IDEMPOTENCY] failed to unlock key %q: %v", key, err)
}
}()

View File

@ -95,15 +95,15 @@ func configDefault(config ...Config) Config {
// Set default values
if int(cfg.Duration.Seconds()) > 0 {
log.Printf("[LIMITER] - [Warning] Duration is deprecated, please use Expiration\n")
log.Printf("[Warning] - [LIMITER] Duration is deprecated, please use Expiration\n")
cfg.Expiration = cfg.Duration
}
if cfg.Key != nil {
log.Printf("[LIMITER] - [Warning] Key is deprecated, please us KeyGenerator\n")
log.Printf("[Warning] - [LIMITER] Key is deprecated, please us KeyGenerator\n")
cfg.KeyGenerator = cfg.Key
}
if cfg.Store != nil {
log.Printf("[LIMITER] - [Warning] Store is deprecated, please use Storage\n")
log.Printf("[Warning] - [LIMITER] Store is deprecated, please use Storage\n")
cfg.Storage = cfg.Store
}
if cfg.Next == nil {

View File

@ -17,7 +17,7 @@ import (
// New is deprecated
func New(config Config) fiber.Handler {
log.Printf("[PROXY] - [Warning] proxy.New is deprecated, please use proxy.Balancer instead\n")
log.Printf("[Warning] - [PROXY] proxy.New is deprecated, please use proxy.Balancer instead\n")
return Balancer(config)
}

View File

@ -97,7 +97,7 @@ func configDefault(config ...Config) Config {
cfg.Expiration = ConfigDefault.Expiration
}
if cfg.CookieName != "" {
log.Printf("[SESSION] - [Warning] CookieName is deprecated, please use KeyLookup\n")
log.Printf("[Warning] - [SESSION] CookieName is deprecated, please use KeyLookup\n")
cfg.KeyLookup = fmt.Sprintf("cookie:%s", cfg.CookieName)
}
if cfg.KeyLookup == "" {

View File

@ -18,7 +18,7 @@ var once sync.Once
// Find documentation and sample usage on https://docs.gofiber.io/api/middleware/timeout
func New(handler fiber.Handler, timeout time.Duration) fiber.Handler {
once.Do(func() {
log.Printf("[TIMEOUT] - [Warning] timeout contains data race issues, not ready for production!")
log.Printf("[Warning] - [TIMEOUT] timeout contains data race issues, not ready for production!")
})
if timeout <= 0 {
@ -32,11 +32,11 @@ func New(handler fiber.Handler, timeout time.Duration) fiber.Handler {
go func() {
defer func() {
if err := recover(); err != nil {
log.Printf("[TIMEOUT] - [Warning] recover error %v", err)
log.Printf("[Warning] - [TIMEOUT] recover error %v", err)
}
}()
if err := handler(ctx); err != nil {
log.Printf("[TIMEOUT] - [Warning] handler error %v", err)
log.Printf("[Warning] - [TIMEOUT] handler error %v", err)
}
ch <- struct{}{}
}()