An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

# resurfaceio-logger-go
Easily log API requests and responses to your own security data lake.

[![Go project version](https://badge.fury.io/go/github.com%2Fresurfaceio%2Flogger-go.svg)](https://badge.fury.io/go/github.com%2Fresurfaceio%2Flogger-go)
[![CodeFactor](https://www.codefactor.io/repository/github/resurfaceio/logger-go/badge)](https://www.codefactor.io/repository/github/resurfaceio/logger-go)
[![License](https://img.shields.io/github/license/resurfaceio/logger-go)](https://github.com/resurfaceio/logger-go/blob/master/LICENSE)
[![Contributing](https://img.shields.io/badge/contributions-welcome-green.svg)](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.

Logging rules documentation

---
© 2016-2024 Graylog, Inc.