aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/Xe/ln
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2018-07-01 20:38:18 +0000
committerChristine Dodrill <me@christine.website>2018-07-01 20:38:18 +0000
commit6197f455f695eb959a932e15dc417c1b50a2255b (patch)
treeeb90c08ea8e688894b033668587635c6e350f13d /vendor/github.com/Xe/ln
parentb0e0b108231f9b71eebe68d8e9b99ca2846b4534 (diff)
downloadxesite-6197f455f695eb959a932e15dc417c1b50a2255b.tar.xz
xesite-6197f455f695eb959a932e15dc417c1b50a2255b.zip
vgo
Diffstat (limited to 'vendor/github.com/Xe/ln')
-rw-r--r--vendor/github.com/Xe/ln/ex/doc.go7
-rw-r--r--vendor/github.com/Xe/ln/ex/gotrace.go68
-rw-r--r--vendor/github.com/Xe/ln/ex/http.go36
-rw-r--r--vendor/github.com/Xe/ln/ex/l2met.go25
-rw-r--r--vendor/github.com/Xe/ln/example/http.go51
5 files changed, 0 insertions, 187 deletions
diff --git a/vendor/github.com/Xe/ln/ex/doc.go b/vendor/github.com/Xe/ln/ex/doc.go
deleted file mode 100644
index 932ed42..0000000
--- a/vendor/github.com/Xe/ln/ex/doc.go
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
-Package ex is a set of extensions and middleware for ln.
-
-This package will (inevitably) have a lot of third-party dependencies and
-as such might be broken apart into other packages in the future.
-*/
-package ex
diff --git a/vendor/github.com/Xe/ln/ex/gotrace.go b/vendor/github.com/Xe/ln/ex/gotrace.go
deleted file mode 100644
index 5579879..0000000
--- a/vendor/github.com/Xe/ln/ex/gotrace.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package ex
-
-import (
- "context"
- "log"
-
- "github.com/Xe/ln"
- "golang.org/x/net/trace"
-)
-
-type goEventLogger struct {
- ev trace.EventLog
-}
-
-// NewGoEventLogger will log ln information to a given trace.EventLog instance.
-func NewGoEventLogger(ev trace.EventLog) ln.Filter {
- return &goEventLogger{ev: ev}
-}
-
-func (gel *goEventLogger) Apply(ctx context.Context, e ln.Event) bool {
- data, err := ln.DefaultFormatter.Format(ctx, e)
- if err != nil {
- log.Printf("wtf: error in log formatting: %v", err)
- return false
- }
-
- if everr := e.Data["err"]; everr != nil {
- gel.ev.Errorf("%s", string(data))
- return true
- }
-
- gel.ev.Printf("%s", string(data))
- return true
-}
-
-func (gel *goEventLogger) Close() { gel.ev.Finish() }
-func (gel *goEventLogger) Run() {}
-
-type sst string
-
-func (s sst) String() string { return string(s) }
-
-func goTraceLogger(ctx context.Context, e ln.Event) bool {
- sp, ok := trace.FromContext(ctx)
- if !ok {
- return true // no trace in context
- }
-
- data, err := ln.DefaultFormatter.Format(ctx, e)
- if err != nil {
- log.Printf("wtf: error in log formatting: %v", err)
- return false
- }
-
- if everr := e.Data["err"]; everr != nil {
- sp.SetError()
- }
-
- sp.LazyLog(sst(string(data)), false)
-
- return true
-}
-
-// NewGoTraceLogger will log ln information to a golang.org/x/net/trace.Trace
-// if it is present in the context of ln calls.
-func NewGoTraceLogger() ln.Filter {
- return ln.FilterFunc(goTraceLogger)
-}
diff --git a/vendor/github.com/Xe/ln/ex/http.go b/vendor/github.com/Xe/ln/ex/http.go
deleted file mode 100644
index c5715a3..0000000
--- a/vendor/github.com/Xe/ln/ex/http.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package ex
-
-import (
- "net"
- "net/http"
- "time"
-
- "github.com/Xe/ln"
-)
-
-func HTTPLog(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- host, _, _ := net.SplitHostPort(r.RemoteAddr)
- f := ln.F{
- "remote_ip": host,
- "x_forwarded_for": r.Header.Get("X-Forwarded-For"),
- "path": r.URL.Path,
- }
- ctx := ln.WithF(r.Context(), f)
- st := time.Now()
-
- next.ServeHTTP(w, r.WithContext(ctx))
-
- af := time.Now()
- f["request_duration"] = af.Sub(st)
-
- ws, ok := w.(interface {
- Status() int
- })
- if ok {
- f["status"] = ws.Status()
- }
-
- ln.Log(r.Context(), f)
- })
-}
diff --git a/vendor/github.com/Xe/ln/ex/l2met.go b/vendor/github.com/Xe/ln/ex/l2met.go
deleted file mode 100644
index e2a7f19..0000000
--- a/vendor/github.com/Xe/ln/ex/l2met.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package ex
-
-import (
- "time"
-
- "github.com/Xe/ln"
-)
-
-// This file deals with formatting of [l2met] style metrics.
-// [l2met]: https://r.32k.io/l2met-introduction
-
-// Counter formats a value as a metrics counter.
-func Counter(name string, value int) ln.Fer {
- return ln.F{"count#" + name: value}
-}
-
-// Gauge formats a value as a metrics gauge.
-func Gauge(name string, value int) ln.Fer {
- return ln.F{"gauge#" + name: value}
-}
-
-// Measure formats a value as a metrics measure.
-func Measure(name string, ts time.Time) ln.Fer {
- return ln.F{"measure#" + name: time.Since(ts)}
-}
diff --git a/vendor/github.com/Xe/ln/example/http.go b/vendor/github.com/Xe/ln/example/http.go
deleted file mode 100644
index 7fb98a3..0000000
--- a/vendor/github.com/Xe/ln/example/http.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// +build ignore
-
-package main
-
-import (
- "context"
- "flag"
- "net/http"
- "time"
-
- "github.com/Xe/ln"
- "github.com/Xe/ln/ex"
- "github.com/facebookgo/flagenv"
- "golang.org/x/net/trace"
-)
-
-var (
- port = flag.String("port", "2145", "http port to listen on")
- tracingFamily = flag.String("trace-family", "ln example", "tracing family to use for x/net/trace")
-)
-
-func main() {
- flagenv.Parse()
- flag.Parse()
-
- ln.DefaultLogger.Filters = append(ln.DefaultLogger.Filters, ex.NewGoTraceLogger())
-
- http.HandleFunc("/", handleIndex)
- http.ListenAndServe(":"+*port, middlewareSpan(ex.HTTPLog(http.DefaultServeMux)))
-}
-
-func middlewareSpan(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- sp := trace.New(*tracingFamily, "HTTP request")
- defer sp.Finish()
- ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)
- defer cancel()
-
- ctx = trace.NewContext(ctx, sp)
-
- next.ServeHTTP(w, r.WithContext(ctx))
- })
-}
-
-func handleIndex(w http.ResponseWriter, r *http.Request) {
- ctx := r.Context()
-
- ln.Log(ctx, ln.Action("index"), ln.F{"there_is": "no_danger"})
-
- http.Error(w, "There is no danger citizen", http.StatusOK)
-}