https://github.com/dre1080/fiberlog
:dna: Logger middleware for fiber using zerolog
https://github.com/dre1080/fiberlog
go gofiber zerolog
Last synced: about 1 month ago
JSON representation
:dna: Logger middleware for fiber using zerolog
- Host: GitHub
- URL: https://github.com/dre1080/fiberlog
- Owner: dre1080
- License: mit
- Created: 2020-06-26T16:30:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-27T08:47:40.000Z (almost 5 years ago)
- Last Synced: 2025-04-12T08:52:37.640Z (about 1 month ago)
- Topics: go, gofiber, zerolog
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 11
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fiberlog
[](https://pkg.go.dev/github.com/dre1080/fiberlog)
HTTP request/response logger for [Fiber](https://github.com/gofiber/fiber) using [zerolog](https://github.com/rs/zerolog).
### Install
```sh
go get -u github.com/gofiber/fiber
go get -u github.com/dre1080/fiberlog
```### Usage
```go
package mainimport (
"github.com/gofiber/fiber"
"github.com/dre1080/fiberlog"
)func main() {
app := fiber.New()// Default
app.Use(fiberlog.New())// Custom Config
app.Use(fiberlog.New(fiberlog.Config{
Logger: &zerolog.New(os.Stdout),
Next: func(ctx *fiber.Ctx) bool {
// skip if we hit /private
return ctx.Path() == "/private"
},
}))app.Listen(3000)
}
```### Example
Run app server:
```sh
$ go run example/main.go
```Test request:
```sh
$ curl http://localhost:3000/ok
$ curl http://localhost:3000/warn
$ curl http://localhost:3000/err
```