Skip to content

Commit

Permalink
📚 Doc: Update logger filter documentation in whats_new.md
Browse files Browse the repository at this point in the history
  • Loading branch information
JIeJaitt committed Mar 3, 2025
1 parent 75976af commit 288edb2
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,29 @@ func main() {

</details>

The `Filter` is a function that is called before the log string for a request is written to Output. If it returns true, the log will be written; otherwise, it will be skipped.

<details>
<summary>Example</summary>

```go
app.Use(logger.New(logger.Config{
Filter: func(c fiber.Ctx) bool {
// Skip logging for 404 requests
return c.Response().StatusCode() == fiber.StatusNotFound
},
}))

app.Use(logger.New(logger.Config{
Filter: func(c fiber.Ctx) bool {
// Only log requests with status code 200
return c.Response().StatusCode() == fiber.StatusOK
},
}))
```

</details>

### Filesystem

We've decided to remove filesystem middleware to clear up the confusion between static and filesystem middleware.
Expand Down Expand Up @@ -940,26 +963,6 @@ The Healthcheck middleware has been enhanced to support more than two routes, wi

Refer to the [healthcheck middleware migration guide](./middleware/healthcheck.md) or the [general migration guide](#-migration-guide) to review the changes.

### Filter

The `Filter` is a function that is called before the log string for a request is written to Output. If it returns true, the log will be written; otherwise, it will be skipped.

```go
app.Use(logger.New(logger.Config{
Filter: func(c fiber.Ctx) bool {
// Skip logging for 404 requests
return c.Response().StatusCode() == fiber.StatusNotFound
},
}))

app.Use(logger.New(logger.Config{
Filter: func(c fiber.Ctx) bool {
// Only log requests with status code 200
return c.Response().StatusCode() == fiber.StatusOK
},
}))
```

## 🔌 Addons

In v3, Fiber introduced Addons. Addons are additional useful packages that can be used in Fiber.
Expand Down

0 comments on commit 288edb2

Please sign in to comment.