Commit 9cfe137e authored by Jeromy's avatar Jeromy

remove loggables dependency

parent 9a5c3cbf
......@@ -2,6 +2,8 @@ package http
import (
"context"
"crypto/rand"
"encoding/base32"
"errors"
"net/http"
"runtime/debug"
......@@ -10,7 +12,6 @@ import (
cmds "github.com/ipfs/go-ipfs-cmds"
logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p-loggables"
cors "github.com/rs/cors"
)
......@@ -132,7 +133,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
defer cancel()
req.Context = logging.ContextWithLoggable(req.Context, loggables.Uuid("requestId"))
req.Context = logging.ContextWithLoggable(req.Context, uuidLoggable())
if cn, ok := w.(http.CloseNotifier); ok {
clientGone := cn.CloseNotify()
go func() {
......@@ -160,6 +161,15 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.root.Call(req, re, h.env)
}
func uuidLoggable() logging.Loggable {
ids := make([]byte, 16)
rand.Read(ids)
return logging.Metadata{
"requestId": base32.HexEncoding.EncodeToString(ids),
}
}
func sanitizedErrStr(err error) string {
s := err.Error()
s = strings.Split(s, "\n")[0]
......
......@@ -29,12 +29,6 @@
"name": "go-ipfs-cmdkit",
"version": "1.1.1"
},
{
"author": "whyrusleeping",
"hash": "QmRPkGkHLB72caXgdDYnoaWigXNWx95BcYDKV1n3KTEpaG",
"name": "go-libp2p-loggables",
"version": "1.1.18"
},
{
"author": "texttheater",
"hash": "QmTVvctiHWZzSDZdyU5wdnXh7VF3kprHSyQFwVChos5qKu",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment