https://github.com/resurfaceio/logger-go
Log API calls with Go
https://github.com/resurfaceio/logger-go
api-logger golang http-logger logger-go
Last synced: about 1 month ago
JSON representation
Log API calls with Go
- Host: GitHub
- URL: https://github.com/resurfaceio/logger-go
- Owner: resurfaceio
- License: apache-2.0
- Created: 2020-09-27T23:52:02.000Z (over 4 years ago)
- Default Branch: dev
- Last Pushed: 2024-06-17T18:51:49.000Z (11 months ago)
- Last Synced: 2025-03-28T00:45:07.759Z (about 2 months ago)
- Topics: api-logger, golang, http-logger, logger-go
- Language: Go
- Homepage:
- Size: 3.66 MB
- Stars: 22
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# resurfaceio-logger-go
Easily log API requests and responses to your own security data lake.[](https://badge.fury.io/go/github.com%2Fresurfaceio%2Flogger-go)
[](https://www.codefactor.io/repository/github/resurfaceio/logger-go)
[](https://github.com/resurfaceio/logger-go/blob/master/LICENSE)
[](https://github.com/resurfaceio/logger-go/blob/master/CONTRIBUTING.md)## Contents
## Dependencies
Requires go 1.18 or later.
## Installation
Run this command in the same directory as your project's `go.mod` and `go.sum` files:
```
go get github.com/resurfaceio/logger-go/v3
```
## Logging from gorilla/mux
```golang
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/resurfaceio/logger-go/v3" //<----- 1
)
func main() {
router := mux.NewRouter()
options := logger.Options{ //<----- 2
Rules: "include_debug\n",
Url: "http://localhost:7701/message",
Enabled: true,
Queue: nil,
}
httpLoggerForMux, err := logger.NewHttpLoggerForMuxOptions(options) //<----- 3
if err != nil {
log.Fatal(err)
}
router.Use(httpLoggerForMux.LogData) //<----- 4
log.Fatal(http.ListenAndServe(":5000", router))
}
```
## Protecting User Privacy
Loggers always have an active set of rules that control what data is logged
and how sensitive data is masked. All of the examples above apply a predefined set of rules, `include_debug`,
but logging rules are easily customized to meet the needs of any application.
---
© 2016-2024 Graylog, Inc.