Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dre1080/fiberlog
:dna: Logger middleware for fiber using zerolog
https://github.com/dre1080/fiberlog
go gofiber zerolog
Last synced: about 2 months 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 (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-27T08:47:40.000Z (over 4 years ago)
- Last Synced: 2024-06-19T03:03:45.043Z (7 months ago)
- Topics: go, gofiber, zerolog
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 11
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fiberlog
[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](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
```![screen](./example/screen.png)