Categorygithub.com/resurfaceio/logger-go/v2
package
2.0.1
Repository: https://github.com/resurfaceio/logger-go.git
Documentation: pkg.go.dev

# README

resurfaceio-logger-go

Easily log API requests and responses to your own system of record.

pkg.go.dev documentation for this Go module.

Contents

Installation

In the same directory as your project's go.mod and go.sum files.

go get github.com/resurfaceio/logger-go

Setup the Resurface app

You can also find these instructions here.

If you don't already have Docker installed, you can do so by following these instructions.

From the terminal, run this Docker command to start up the Resurface app using docker.

docker run -d --name resurface -p 4000:4000 -p 4001:4001 -p 4002:4002 resurfaceio/resurface:2.3.1

Point your browser at http://localhost:4002.

Logging from gorilla/mux

package main

import (
	"log"
	"net/http"

	"github.com/gorilla/mux"
	"github.com/resurfaceio/logger-go" //<----- 1
)


func main() {
	router := mux.NewRouter()
  
	options := logger.Options{ //<----- 2
		Rules:   "include_debug\n",
		Url:     "http://localhost:4001/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