Repository: gofiber/fiber (Go)

Issue:
🐛 [Bug]: FiberApp adaptor initializes fasthttp.RequestCtx with nil logger
### Bug Description

Using Fiber v3.0.0-beta.3, I found that my application was logging errors when serving static content where the file didn't exist when using the FiberApp adaptor middleware to convert the app to a `http.HandlerFunc` interface.

Not a huge issue, but rather a small annoyance.

Example:
2024/09/12 17:19:23 0.001 #0000000100000000 - 0.0.0.0:0<->127.0.0.1:53221 - GET http://localhost:8080/notfound - cannot open file "C:\\path\\to\\file\\does\\not\\exist\\notfound": open C:\\path\\to\\file\\does\\not\\exist\\notfound: The system cannot find the file specified.

It looks like the `fasthttp.RequestCtx` is being initialized with a nil logger in `adaptor.handlerFunc()` causing fasthttp to use the default logger when `fasthttp.RequestCtx.Init()` is invoked

```go
// New fasthttp Ctx
var fctx fasthttp.RequestCtx
fctx.Init(req, remoteAddr, nil) // <-- Nil logger being provided
if len(h) > 0 {
	// New fiber Ctx
	ctx := app.AcquireCtx(&fctx)
	// Execute fiber Ctx
	err := h[0](ctx)
	if err != nil {
		_ = app.Config().ErrorHandler(ctx, err) //nolint:errcheck // not needed
	}
} else {
	// Execute fasthttp Ctx though app.Handler
	app.Handler()(&fctx)
}
```

### How to Reproduce

Steps to reproduce the behavior:
1. Create a new Fiber App
```go
app := fiber.New()
```
2. Serve static files
```go
app.Get("/*", static.New("/path/to/static/files")
```
3. Convert app to http.HandlerFunc
```go
var h http.Handler = adaptor.FiberApp(app)
```
4. ListenAndServe
```go
server := &http.Server{
    Handler: h,
    Addr: ":8080"
}

panic(server.ListenAndServe())
```
5. Navigate to something in browser that doesn't exist and view logs i.e. localhost:8080/notexists


### Expected Behavior

Expecting the Noop logger to be invoked, leading to no logs being written.

### Fiber Version

v3.0.0-beta.3

### Code Snippet (optional)

```go
package main

import (
	"log"
	"net/http"

	"github.com/gofiber/fiber/v3"
	"github.com/gofiber/fiber/v3/middleware/adaptor"
	"github.com/gofiber/fiber/v3/middleware/static"
)

func main() {
	app := fiber.New()

	// Contains an index.html only
	app.Get("/*", static.New("./templates"))

	var h http.Handler = adaptor.FiberApp(app)

	server := &http.Server{
		Handler: h,
		Addr:    ":8080",
	}

	log.Fatal(server.ListenAndServe())
}
```


### Checklist:

- [X] I agree to follow Fiber's [Code of Conduct](https://github.com/gofiber/fiber/blob/master/.github/CODE_OF_CONDUCT.md).
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.


Discussion:
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

Seems like we need a `NoopLogger` here, to be able to solved this. The other option is to have `fasthttp` change their code but that would be a longer time to fix
Agreed. I expected the `disableLogger` that is used to init the `fasthttp.Server` would be used. 
That does seem to be the case when the adaptor middleware isn't used.
Yeah, I will fix it



Patch:
diff --git a/middleware/adaptor/adaptor.go b/middleware/adaptor/adaptor.go
index 539aa3e24b..a5040b39ae 100644
--- a/middleware/adaptor/adaptor.go
+++ b/middleware/adaptor/adaptor.go
@@ -14,6 +14,11 @@ import (
 	"github.com/valyala/fasthttp/fasthttpadaptor"
 )
 
+type disableLogger struct{}
+
+func (*disableLogger) Printf(string, ...any) {
+}
+
 var ctxPool = sync.Pool{
 	New: func() any {
 		return new(fasthttp.RequestCtx)
@@ -171,7 +176,7 @@ func handlerFunc(app *fiber.App, h ...fiber.Handler) http.HandlerFunc {
 		fctx.Response.Reset()
 		fctx.Request.Reset()
 		defer ctxPool.Put(fctx)
-		fctx.Init(req, remoteAddr, nil)
+		fctx.Init(req, remoteAddr, &disableLogger{})
 
 		if len(h) > 0 {
 			// New fiber Ctx


Test patch:
diff --git a/middleware/adaptor/adaptor_test.go b/middleware/adaptor/adaptor_test.go
index 32abc64d93..c703d38436 100644
--- a/middleware/adaptor/adaptor_test.go
+++ b/middleware/adaptor/adaptor_test.go
@@ -86,7 +86,7 @@ func Test_HTTPHandler(t *testing.T) {
 	remoteAddr, err := net.ResolveTCPAddr("tcp", expectedRemoteAddr)
 	require.NoError(t, err)
 
-	fctx.Init(&req, remoteAddr, nil)
+	fctx.Init(&req, remoteAddr, &disableLogger{})
 	app := fiber.New()
 	ctx := app.AcquireCtx(&fctx)
 	defer app.ReleaseCtx(ctx)
@@ -412,6 +412,10 @@ func Benchmark_FiberHandlerFunc(b *testing.B) {
 		name        string
 		bodyContent []byte
 	}{
+		{
+			name:        "No Content",
+			bodyContent: nil, // No body content case
+		},
 		{
 			name:        "100KB",
 			bodyContent: make([]byte, 100*1024),
@@ -450,7 +454,14 @@ func Benchmark_FiberHandlerFunc(b *testing.B) {
 	for _, bm := range benchmarks {
 		b.Run(bm.name, func(b *testing.B) {
 			w := httptest.NewRecorder()
-			bodyBuffer := bytes.NewBuffer(bm.bodyContent)
+			var bodyBuffer *bytes.Buffer
+
+			// Handle the "No Content" case where bodyContent is nil
+			if bm.bodyContent != nil {
+				bodyBuffer = bytes.NewBuffer(bm.bodyContent)
+			} else {
+				bodyBuffer = bytes.NewBuffer([]byte{}) // Empty buffer for no content
+			}
 
 			r := http.Request{
 				Method: http.MethodPost,
@@ -476,6 +487,10 @@ func Benchmark_FiberHandlerFunc_Parallel(b *testing.B) {
 		name        string
 		bodyContent []byte
 	}{
+		{
+			name:        "No Content",
+			bodyContent: nil, // No body content case
+		},
 		{
 			name:        "100KB",
 			bodyContent: make([]byte, 100*1024),
@@ -513,7 +528,15 @@ func Benchmark_FiberHandlerFunc_Parallel(b *testing.B) {
 
 	for _, bm := range benchmarks {
 		b.Run(bm.name, func(b *testing.B) {
-			bodyBuffer := bytes.NewBuffer(bm.bodyContent)
+			var bodyBuffer *bytes.Buffer
+
+			// Handle the "No Content" case where bodyContent is nil
+			if bm.bodyContent != nil {
+				bodyBuffer = bytes.NewBuffer(bm.bodyContent)
+			} else {
+				bodyBuffer = bytes.NewBuffer([]byte{}) // Empty buffer for no content
+			}
+
 			b.ReportAllocs()
 			b.ResetTimer()