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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug]:Incorrect log depth when use log.WithContext #2646

Closed
3 tasks done
0xmkzt opened this issue Sep 25, 2023 · 5 comments
Closed
3 tasks done

🐛 [Bug]:Incorrect log depth when use log.WithContext #2646

0xmkzt opened this issue Sep 25, 2023 · 5 comments
Assignees

Comments

@0xmkzt
Copy link

0xmkzt commented Sep 25, 2023

Bug Description

When i use log.WithContext, the log depth is more deeper.

How to Reproduce

Steps to reproduce the behavior:

  1. Run the code snippet
  2. Invoke interface curl -i http://127.0.0.1:3000/ready
  3. You can see ...router.go:145: [Info] ready

Expected Behavior

Actually it should be ...main.go:14: [Info] ready

Fiber Version

v2.49.2

Code Snippet (optional)

package main

import (
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/log"
)

func main() {
	app := fiber.New()
	app.Get("/ready", func(c *fiber.Ctx) error {
		log.Info(">>>")
		log.WithContext(c.UserContext()).Info("ready")
		log.Info("<<<")
		return c.SendString("ready")
	})
	err := app.Listen(":3000")
	if err != nil {
		log.Error(err)
		return
	}
}

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.
@welcome
Copy link

welcome bot commented Sep 25, 2023

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

@0xmkzt 0xmkzt changed the title 🐛 [Bug]:Incorrect caller when use log.WithContext 🐛 [Bug]:Incorrect log depth when use log.WithContext Sep 25, 2023
0xmkzt added a commit to 0xmkzt/fiber that referenced this issue Sep 25, 2023
@ReneWerner87
Copy link
Member

Duplicate of gofiber/contrib#791

@ReneWerner87
Copy link
Member

@Skyenought can you help here?

@nikzayn
Copy link

nikzayn commented Oct 2, 2023

I would like to take this up!

/assign

@Skyenought Skyenought self-assigned this Oct 7, 2023
@Skyenought
Copy link
Member

i will fix bug in fiber soon

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

4 participants