https://github.com/fs02/logrus-filtered-formatter
Logrus JSON Formatter with filterable fields
https://github.com/fs02/logrus-filtered-formatter
Last synced: over 1 year ago
JSON representation
Logrus JSON Formatter with filterable fields
- Host: GitHub
- URL: https://github.com/fs02/logrus-filtered-formatter
- Owner: Fs02
- License: mit
- Created: 2017-09-27T10:03:18.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-28T05:46:50.000Z (over 8 years ago)
- Last Synced: 2024-06-21T01:45:58.766Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logrus Filtered Formatter
Use this formatter to log json with filtered fields
## Usage
```
package main
import (
"github.com/Fs02/logrus-filtered-formatter"
"github.com/sirupsen/logrus"
)
func main() {
log := logrus.New()
fields := []string{
"password",
"email",
}
log.Formatter = filtered.New(fields, &logrus.JSONFormatter{})
log.WithFields(logrus.Fields{
"password": "asdfasdf",
"email": "johndoe@gmail.com",
"name": "john doe",
}).Info("new user created")
}
```
Output:
```
{"email":[FILTERED],"level":"info","msg":"new user created","name":"john doe","password":[FILTERED],"time":"2017-10-05T16:05:29+07:00"}
```