canonicallog

package module
v0.0.0-...-1154b2b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2024 License: MIT Imports: 7 Imported by: 0

README

canonical log

A canonical logging solution for Go inspired from https://stripe.com/blog/canonical-log-lines

Install

go get github.com/remicaumette/canonicallog

HTTP

package main

import (
    "net/http"
    "log/slog"
    "github.com/remicaumette/canonicallog"
)

func main()  {
    handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
      canonicallog.LogAttr(r.Context(), slog.String("user_id", "123"))
      w.WriteHeader(http.StatusNoContent)
    })
    http.ListenAndServe("0.0.0.0:3000", canonicallog.HttpHandler(handler))
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL