Skip to content

Commit

Permalink
Fix markdownlint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby authored Nov 30, 2024
1 parent 2b2b5fe commit 25f2952
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 50 deletions.
1 change: 0 additions & 1 deletion docs/api/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,3 @@ if !ok {

stdlogger.SetFlags(0) // Hide timestamp by setting flags to 0
```

44 changes: 22 additions & 22 deletions docs/middleware/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,33 @@ In order to use Fiber logger middleware with other loggers such as zerolog, zap,
package main

import (
"github.com/gofiber/contrib/fiberzap/v2"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/log"
"github.com/gofiber/fiber/v3/middleware/logger"
"github.com/gofiber/contrib/fiberzap/v2"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/log"
"github.com/gofiber/fiber/v3/middleware/logger"
)

func main() {
// Create a new Fiber instance
app := fiber.New()
// Create a new Fiber instance
app := fiber.New()

// Create a new zap logger which is compatible with Fiber AllLogger interface
zap := fiberzap.NewLogger(fiberzap.LoggerConfig{
ExtraKeys: []string{"request_id"},
})

// Use the logger middleware with zerolog logger
app.Use(logger.New(logger.Config{
Output: logger.LoggerToWriter(zap, log.LevelDebug),
}))

// Define a route
app.Get("/", func(c fiber.Ctx) error {
return c.SendString("Hello, World!")
})

// Start server on http://localhost:3000
app.Listen(":3000")
zap := fiberzap.NewLogger(fiberzap.LoggerConfig{
ExtraKeys: []string{"request_id"},
})

// Use the logger middleware with zerolog logger
app.Use(logger.New(logger.Config{
Output: logger.LoggerToWriter(zap, log.LevelDebug),
}))

// Define a route
app.Get("/", func(c fiber.Ctx) error {
return c.SendString("Hello, World!")
})

// Start server on http://localhost:3000
app.Listen(":3000")
}
```

Expand Down
53 changes: 26 additions & 27 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ curl "http://localhost:3000/header"

## 📃 Log

`fiber.AllLogger` interface now has a new method called `GetLoggerInstance`. This method can be used to get the underlying logger instance from the Fiber logger middleware. This is useful when you want to configure the logger middleware with a custom logger and still want to access the underlying logger instance.
`fiber.AllLogger` interface now has a new method called `GetLoggerInstance`. This method can be used to get the underlying logger instance from the Fiber logger middleware. This is useful when you want to configure the logger middleware with a custom logger and still want to access the underlying logger instance.

You can find more details about this feature in [/docs/api/log.md](./api/log.md#getloggerinstance).

Expand Down Expand Up @@ -714,40 +714,39 @@ For more details on these changes and migration instructions, check the [Session

### Logger

New helper function called `LoggerToWriter` has been added to the logger middleware.
This function allows you to use 3rd party loggers such as `logrus` or `zap` with the Fiber logger middleware without any extra afford. For example, you can use `zap` with Fiber logger middleware like this:
New helper function called `LoggerToWriter` has been added to the logger middleware. This function allows you to use 3rd party loggers such as `logrus` or `zap` with the Fiber logger middleware without any extra afford. For example, you can use `zap` with Fiber logger middleware like this:

```go
package main

import (
"github.com/gofiber/contrib/fiberzap/v2"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/log"
"github.com/gofiber/fiber/v3/middleware/logger"
"github.com/gofiber/contrib/fiberzap/v2"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/log"
"github.com/gofiber/fiber/v3/middleware/logger"
)

func main() {
// Create a new Fiber instance
app := fiber.New()

// Create a new zap logger which is compatible with Fiber AllLogger interface
zap := fiberzap.NewLogger(fiberzap.LoggerConfig{
ExtraKeys: []string{"request_id"},
})

// Use the logger middleware with zerolog logger
app.Use(logger.New(logger.Config{
Output: logger.LoggerToWriter(zap, log.LevelDebug),
}))

// Define a route
app.Get("/", func(c fiber.Ctx) error {
return c.SendString("Hello, World!")
})

// Start server on http://localhost:3000
app.Listen(":3000")
// Create a new Fiber instance
app := fiber.New()

// Create a new zap logger which is compatible with Fiber AllLogger interface
zap := fiberzap.NewLogger(fiberzap.LoggerConfig{
ExtraKeys: []string{"request_id"},
})

// Use the logger middleware with zerolog logger
app.Use(logger.New(logger.Config{
Output: logger.LoggerToWriter(zap, log.LevelDebug),
}))

// Define a route
app.Get("/", func(c fiber.Ctx) error {
return c.SendString("Hello, World!")
})

// Start server on http://localhost:3000
app.Listen(":3000")
}
```

Expand Down

0 comments on commit 25f2952

Please sign in to comment.