Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moul/chizap
⚡️ simple zap logging middleware for go-chi
https://github.com/moul/chizap
chi go-chi golang logger middleware uber-zap zap
Last synced: about 5 hours ago
JSON representation
⚡️ simple zap logging middleware for go-chi
- Host: GitHub
- URL: https://github.com/moul/chizap
- Owner: moul
- License: other
- Created: 2021-06-24T13:16:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-25T18:59:56.000Z (8 days ago)
- Last Synced: 2024-10-02T19:59:49.133Z (about 17 hours ago)
- Topics: chi, go-chi, golang, logger, middleware, uber-zap, zap
- Language: Go
- Homepage: https://manfred.life/golang
- Size: 69.3 KB
- Stars: 22
- Watchers: 3
- Forks: 1
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
- Support: .github/SUPPORT.md
- Authors: AUTHORS
Awesome Lists containing this project
README
# chizap
:smile: chizap
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/moul.io/chizap)
[![License](https://img.shields.io/badge/license-Apache--2.0%20%2F%20MIT-%2397ca00.svg)](https://github.com/moul/chizap/blob/main/COPYRIGHT)
[![GitHub release](https://img.shields.io/github/release/moul/chizap.svg)](https://github.com/moul/chizap/releases)
[![Docker Metrics](https://images.microbadger.com/badges/image/moul/chizap.svg)](https://microbadger.com/images/moul/chizap)
[![Made by Manfred Touron](https://img.shields.io/badge/made%20by-Manfred%20Touron-blue.svg?style=flat)](https://manfred.life/)[![Go](https://github.com/moul/chizap/workflows/Go/badge.svg)](https://github.com/moul/chizap/actions?query=workflow%3AGo)
[![Release](https://github.com/moul/chizap/workflows/Release/badge.svg)](https://github.com/moul/chizap/actions?query=workflow%3ARelease)
[![PR](https://github.com/moul/chizap/workflows/PR/badge.svg)](https://github.com/moul/chizap/actions?query=workflow%3APR)
[![GolangCI](https://golangci.com/badges/github.com/moul/chizap.svg)](https://golangci.com/r/github.com/moul/chizap)
[![codecov](https://codecov.io/gh/moul/chizap/branch/main/graph/badge.svg)](https://codecov.io/gh/moul/chizap)
[![Go Report Card](https://goreportcard.com/badge/moul.io/chizap)](https://goreportcard.com/report/moul.io/chizap)
[![CodeFactor](https://www.codefactor.io/repository/github/moul/chizap/badge)](https://www.codefactor.io/repository/github/moul/chizap)[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/moul/chizap)
## Example
[embedmd]:# (example_test.go /import\ / $)
```go
import (
"github.com/go-chi/chi"
"go.uber.org/zap"
"moul.io/chizap"
)func Example() {
logger := zap.NewExample()
r := chi.NewRouter()
r.Use(chizap.New(logger, &chizap.Opts{
WithReferer: true,
WithUserAgent: true,
}))
}
```## Usage
[embedmd]:# (.tmp/godoc.txt txt /FUNCTIONS/ $)
```txt
FUNCTIONSfunc New(logger *zap.Logger, opts *Opts) func(next http.Handler) http.Handler
New returns a logger middleware for chi, that implements the http.Handler
interface.TYPES
type Opts struct {
// WithReferer enables logging the "Referer" HTTP header value.
WithReferer bool// WithUserAgent enables logging the "User-Agent" HTTP header value.
WithUserAgent bool
}
Opts contains the middleware configuration.```
## Install
### Using go
```sh
go get moul.io/chizap
```### Releases
See https://github.com/moul/chizap/releases
## Contribute
![Contribute <3](https://raw.githubusercontent.com/moul/moul/main/contribute.gif)
I really welcome contributions.
Your input is the most precious material.
I'm well aware of that and I thank you in advance.
Everyone is encouraged to look at what they can do on their own scale;
no effort is too small.Everything on contribution is sum up here: [CONTRIBUTING.md](./.github/CONTRIBUTING.md)
### Dev helpers
Pre-commit script for install: https://pre-commit.com
### Contributors ✨
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg)](#contributors)
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Manfred Touron
🚧 📖 ⚠️ 💻
moul-bot
🚧
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!### Stargazers over time
[![Stargazers over time](https://starchart.cc/moul/chizap.svg)](https://starchart.cc/moul/chizap)
## License
© 2021 [Manfred Touron](https://manfred.life)
Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
([`LICENSE-APACHE`](LICENSE-APACHE)) or the [MIT license](https://opensource.org/licenses/MIT)
([`LICENSE-MIT`](LICENSE-MIT)), at your option.
See the [`COPYRIGHT`](COPYRIGHT) file for more details.`SPDX-License-Identifier: (Apache-2.0 OR MIT)`