Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 logger custom formatting is ignored #1625

Closed
husanu opened this issue Nov 16, 2021 · 4 comments
Closed

馃悰 logger custom formatting is ignored #1625

husanu opened this issue Nov 16, 2021 · 4 comments

Comments

@husanu
Copy link

husanu commented Nov 16, 2021

Fiber version
github.com/gofiber/fiber/v2 v2.22.0

Issue description

because of https://github.com/gofiber/fiber/blob/master/middleware/logger/config.go#L85 if Output == nil and Format contains ${status} and ${method}" then cfg.enableColors is set to true, which will force the code for no custom format to run:

// https://github.com/gofiber/fiber/blob/master/middleware/logger/logger.go#L177
  // Default output when no custom Format or io.Writer is given
  if cfg.enableColors {}

Code snippet

package main

import (
  "github.com/gofiber/fiber/v2"
  "github.com/gofiber/fiber/v2/middleware/logger"
)

func main() {
  app := fiber.New()

  // Steps to reproduce
  app.Use(logger.New(logger.Config{
    Format: ">>> [${time}] ${ip} ${host} ${status} - ${latency} ${method} ${path} ${url}\n",
    // DEFAULT Format: "[${time}] ${status} - ${latency} ${method} ${path}\n",
  }))

  log.Fatal(app.Listen(":3000"))
}
@welcome
Copy link

welcome bot commented Nov 16, 2021

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@ReneWerner87
Copy link
Member

#1609

@husanu
Copy link
Author

husanu commented Nov 17, 2021

#1609

same buggy code... different side effect :)

@ReneWerner87
Copy link
Member

Duplicate of #1609

@ReneWerner87 ReneWerner87 marked this as a duplicate of #1609 Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants