aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/Xe/ln
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/Xe/ln')
-rw-r--r--vendor/github.com/Xe/ln/LICENSE25
-rw-r--r--vendor/github.com/Xe/ln/README.md29
-rw-r--r--vendor/github.com/Xe/ln/action.go11
-rw-r--r--vendor/github.com/Xe/ln/context.go38
-rw-r--r--vendor/github.com/Xe/ln/doc.go25
-rw-r--r--vendor/github.com/Xe/ln/filter.go67
-rw-r--r--vendor/github.com/Xe/ln/formatter.go111
-rw-r--r--vendor/github.com/Xe/ln/logger.go180
-rw-r--r--vendor/github.com/Xe/ln/stack.go44
9 files changed, 0 insertions, 530 deletions
diff --git a/vendor/github.com/Xe/ln/LICENSE b/vendor/github.com/Xe/ln/LICENSE
deleted file mode 100644
index 7202b64..0000000
--- a/vendor/github.com/Xe/ln/LICENSE
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2015, Andrew Gwozdziewycz
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-1. Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/vendor/github.com/Xe/ln/README.md b/vendor/github.com/Xe/ln/README.md
deleted file mode 100644
index 61fc941..0000000
--- a/vendor/github.com/Xe/ln/README.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# ln: The Natural Logger for Go
-
-`ln` provides a simple interface to logging, and metrics, and
-obviates the need to utilize purpose built metrics packages, like
-`go-metrics` for simple use cases.
-
-The design of `ln` centers around the idea of key-value pairs, which
-can be interpreted on the fly, but "Filters" to do things such as
-aggregated metrics, and report said metrics to, say Librato, or
-statsd.
-
-"Filters" are like WSGI, or Rack Middleware. They are run "top down"
-and can abort an emitted log's output at any time, or continue to let
-it through the chain. However, the interface is slightly different
-than that. Rather than encapsulating the chain with partial function
-application, we utilize a simpler method, namely, each plugin defines
-an `Apply` function, which takes as an argument the log event, and
-performs the work of the plugin, only if the Plugin "Applies" to this
-log event.
-
-If `Apply` returns `false`, the iteration through the rest of the
-filters is aborted, and the log is dropped from further processing.
-
-## Current Status: Initial Development / Concept
-
-## Copyright
-
-(c) 2015, Andrew Gwozdziewycz, BSD Licensed. See LICENSE for more
-info.
diff --git a/vendor/github.com/Xe/ln/action.go b/vendor/github.com/Xe/ln/action.go
deleted file mode 100644
index 54f8954..0000000
--- a/vendor/github.com/Xe/ln/action.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package ln
-
-// Action is a convenience helper for logging the "action" being performed as
-// part of a log line.
-//
-// It is a convenience wrapper for the following:
-//
-// ln.Log(ctx, fer, f, ln.Action("writing frozberry sales reports to database"))
-func Action(act string) Fer {
- return F{"action": act}
-}
diff --git a/vendor/github.com/Xe/ln/context.go b/vendor/github.com/Xe/ln/context.go
deleted file mode 100644
index 0ea3229..0000000
--- a/vendor/github.com/Xe/ln/context.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package ln
-
-import (
- "context"
-)
-
-type ctxKey int
-
-const (
- fKey = iota
-)
-
-// WithF stores or appends a given F instance into a context.
-func WithF(ctx context.Context, f F) context.Context {
- pf, ok := FFromContext(ctx)
- if !ok {
- return context.WithValue(ctx, fKey, f)
- }
-
- pf.Extend(f)
-
- return context.WithValue(ctx, fKey, pf)
-}
-
-// FFromContext fetches the `F` out of the context if it exists.
-func FFromContext(ctx context.Context) (F, bool) {
- fvp := ctx.Value(fKey)
- if fvp == nil {
- return nil, false
- }
-
- f, ok := fvp.(F)
- if !ok {
- return nil, false
- }
-
- return f, true
-}
diff --git a/vendor/github.com/Xe/ln/doc.go b/vendor/github.com/Xe/ln/doc.go
deleted file mode 100644
index ab81c3c..0000000
--- a/vendor/github.com/Xe/ln/doc.go
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Package ln is the Natural Logger for Go
-
-`ln` provides a simple interface to logging, and metrics, and
-obviates the need to utilize purpose built metrics packages, like
-`go-metrics` for simple use cases.
-
-The design of `ln` centers around the idea of key-value pairs, which
-can be interpreted on the fly, but "Filters" to do things such as
-aggregated metrics, and report said metrics to, say Librato, or
-statsd.
-
-"Filters" are like WSGI, or Rack Middleware. They are run "top down"
-and can abort an emitted log's output at any time, or continue to let
-it through the chain. However, the interface is slightly different
-than that. Rather than encapsulating the chain with partial function
-application, we utilize a simpler method, namely, each plugin defines
-an `Apply` function, which takes as an argument the log event, and
-performs the work of the plugin, only if the Plugin "Applies" to this
-log event.
-
-If `Apply` returns `false`, the iteration through the rest of the
-filters is aborted, and the log is dropped from further processing.
-*/
-package ln
diff --git a/vendor/github.com/Xe/ln/filter.go b/vendor/github.com/Xe/ln/filter.go
deleted file mode 100644
index 4f2d006..0000000
--- a/vendor/github.com/Xe/ln/filter.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package ln
-
-import (
- "context"
- "io"
- "sync"
-)
-
-// Filter interface for defining chain filters
-type Filter interface {
- Apply(ctx context.Context, e Event) bool
- Run()
- Close()
-}
-
-// FilterFunc allows simple functions to implement the Filter interface
-type FilterFunc func(ctx context.Context, e Event) bool
-
-// Apply implements the Filter interface
-func (ff FilterFunc) Apply(ctx context.Context, e Event) bool {
- return ff(ctx, e)
-}
-
-// Run implements the Filter interface
-func (ff FilterFunc) Run() {}
-
-// Close implements the Filter interface
-func (ff FilterFunc) Close() {}
-
-// WriterFilter implements a filter, which arbitrarily writes to an io.Writer
-type WriterFilter struct {
- sync.Mutex
- Out io.Writer
- Formatter Formatter
-}
-
-// NewWriterFilter creates a filter to add to the chain
-func NewWriterFilter(out io.Writer, format Formatter) *WriterFilter {
- if format == nil {
- format = DefaultFormatter
- }
- return &WriterFilter{
- Out: out,
- Formatter: format,
- }
-}
-
-// Apply implements the Filter interface
-func (w *WriterFilter) Apply(ctx context.Context, e Event) bool {
- output, err := w.Formatter.Format(ctx, e)
- if err == nil {
- w.Lock()
- w.Out.Write(output)
- w.Unlock()
- }
-
- return true
-}
-
-// Run implements the Filter interface
-func (w *WriterFilter) Run() {}
-
-// Close implements the Filter interface
-func (w *WriterFilter) Close() {}
-
-// NilFilter is safe to return as a Filter, but does nothing
-var NilFilter = FilterFunc(func(_ context.Context, e Event) bool { return true })
diff --git a/vendor/github.com/Xe/ln/formatter.go b/vendor/github.com/Xe/ln/formatter.go
deleted file mode 100644
index 70313fc..0000000
--- a/vendor/github.com/Xe/ln/formatter.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package ln
-
-import (
- "bytes"
- "context"
- "fmt"
- "time"
-)
-
-var (
- // DefaultTimeFormat represents the way in which time will be formatted by default
- DefaultTimeFormat = time.RFC3339
-)
-
-// Formatter defines the formatting of events
-type Formatter interface {
- Format(ctx context.Context, e Event) ([]byte, error)
-}
-
-// DefaultFormatter is the default way in which to format events
-var DefaultFormatter Formatter
-
-func init() {
- DefaultFormatter = NewTextFormatter()
-}
-
-// TextFormatter formats events as key value pairs.
-// Any remaining text not wrapped in an instance of `F` will be
-// placed at the end.
-type TextFormatter struct {
- TimeFormat string
-}
-
-// NewTextFormatter returns a Formatter that outputs as text.
-func NewTextFormatter() Formatter {
- return &TextFormatter{TimeFormat: DefaultTimeFormat}
-}
-
-// Format implements the Formatter interface
-func (t *TextFormatter) Format(_ context.Context, e Event) ([]byte, error) {
- var writer bytes.Buffer
-
- writer.WriteString("time=\"")
- writer.WriteString(e.Time.Format(t.TimeFormat))
- writer.WriteString("\"")
-
- keys := make([]string, len(e.Data))
- i := 0
-
- for k := range e.Data {
- keys[i] = k
- i++
- }
-
- for _, k := range keys {
- v := e.Data[k]
-
- writer.WriteByte(' ')
- if shouldQuote(k) {
- writer.WriteString(fmt.Sprintf("%q", k))
- } else {
- writer.WriteString(k)
- }
-
- writer.WriteByte('=')
-
- switch v.(type) {
- case string:
- vs, _ := v.(string)
- if shouldQuote(vs) {
- fmt.Fprintf(&writer, "%q", vs)
- } else {
- writer.WriteString(vs)
- }
- case error:
- tmperr, _ := v.(error)
- es := tmperr.Error()
-
- if shouldQuote(es) {
- fmt.Fprintf(&writer, "%q", es)
- } else {
- writer.WriteString(es)
- }
- case time.Time:
- tmptime, _ := v.(time.Time)
- writer.WriteString(tmptime.Format(time.RFC3339))
- default:
- fmt.Fprint(&writer, v)
- }
- }
-
- if len(e.Message) > 0 {
- fmt.Fprintf(&writer, " _msg=%q", e.Message)
- }
-
- writer.WriteByte('\n')
- return writer.Bytes(), nil
-}
-
-func shouldQuote(s string) bool {
- for _, b := range s {
- if !((b >= 'A' && b <= 'Z') ||
- (b >= 'a' && b <= 'z') ||
- (b >= '0' && b <= '9') ||
- (b == '-' || b == '.' || b == '#' ||
- b == '/' || b == '_')) {
- return true
- }
- }
- return false
-}
diff --git a/vendor/github.com/Xe/ln/logger.go b/vendor/github.com/Xe/ln/logger.go
deleted file mode 100644
index 79a9a63..0000000
--- a/vendor/github.com/Xe/ln/logger.go
+++ /dev/null
@@ -1,180 +0,0 @@
-package ln
-
-import (
- "context"
- "os"
- "time"
-
- "github.com/pkg/errors"
-)
-
-// Logger holds the current priority and list of filters
-type Logger struct {
- Filters []Filter
-}
-
-// DefaultLogger is the default implementation of Logger
-var DefaultLogger *Logger
-
-func init() {
- var defaultFilters []Filter
-
- // Default to STDOUT for logging, but allow LN_OUT to change it.
- out := os.Stdout
- if os.Getenv("LN_OUT") == "<stderr>" {
- out = os.Stderr
- }
-
- defaultFilters = append(defaultFilters, NewWriterFilter(out, nil))
-
- DefaultLogger = &Logger{
- Filters: defaultFilters,
- }
-}
-
-// F is a key-value mapping for structured data.
-type F map[string]interface{}
-
-// Extend concatentates one F with one or many Fer instances.
-func (f F) Extend(other ...Fer) {
- for _, ff := range other {
- for k, v := range ff.F() {
- f[k] = v
- }
- }
-}
-
-// F makes F an Fer
-func (f F) F() F {
- return f
-}
-
-// Fer allows any type to add fields to the structured logging key->value pairs.
-type Fer interface {
- F() F
-}
-
-// Event represents an event
-type Event struct {
- Time time.Time
- Data F
- Message string
-}
-
-// Log is the generic logging method.
-func (l *Logger) Log(ctx context.Context, xs ...Fer) {
- event := Event{Time: time.Now()}
-
- addF := func(bf F) {
- if event.Data == nil {
- event.Data = bf
- } else {
- for k, v := range bf {
- event.Data[k] = v
- }
- }
- }
-
- for _, f := range xs {
- addF(f.F())
- }
-
- ctxf, ok := FFromContext(ctx)
- if ok {
- addF(ctxf)
- }
-
- if os.Getenv("LN_DEBUG_ALL_EVENTS") == "1" {
- frame := callersFrame()
- if event.Data == nil {
- event.Data = make(F)
- }
- event.Data["_lineno"] = frame.lineno
- event.Data["_function"] = frame.function
- event.Data["_filename"] = frame.filename
- }
-
- l.filter(ctx, event)
-}
-
-func (l *Logger) filter(ctx context.Context, e Event) {
- for _, f := range l.Filters {
- if !f.Apply(ctx, e) {
- return
- }
- }
-}
-
-// Error logs an error and information about the context of said error.
-func (l *Logger) Error(ctx context.Context, err error, xs ...Fer) {
- data := F{}
- frame := callersFrame()
-
- data["_lineno"] = frame.lineno
- data["_function"] = frame.function
- data["_filename"] = frame.filename
- data["err"] = err
-
- cause := errors.Cause(err)
- if cause != nil {
- data["cause"] = cause.Error()
- }
-
- xs = append(xs, data)
-
- l.Log(ctx, xs...)
-}
-
-// Fatal logs this set of values, then exits with status code 1.
-func (l *Logger) Fatal(ctx context.Context, xs ...Fer) {
- xs = append(xs, F{"fatal": true})
-
- l.Log(ctx, xs...)
-
- os.Exit(1)
-}
-
-// FatalErr combines Fatal and Error.
-func (l *Logger) FatalErr(ctx context.Context, err error, xs ...Fer) {
- xs = append(xs, F{"fatal": true})
-
- data := F{}
- frame := callersFrame()
-
- data["_lineno"] = frame.lineno
- data["_function"] = frame.function
- data["_filename"] = frame.filename
- data["err"] = err
-
- cause := errors.Cause(err)
- if cause != nil {
- data["cause"] = cause.Error()
- }
-
- xs = append(xs, data)
- l.Log(ctx, xs...)
-
- os.Exit(1)
-}
-
-// Default Implementation
-
-// Log is the generic logging method.
-func Log(ctx context.Context, xs ...Fer) {
- DefaultLogger.Log(ctx, xs...)
-}
-
-// Error logs an error and information about the context of said error.
-func Error(ctx context.Context, err error, xs ...Fer) {
- DefaultLogger.Error(ctx, err, xs...)
-}
-
-// Fatal logs this set of values, then exits with status code 1.
-func Fatal(ctx context.Context, xs ...Fer) {
- DefaultLogger.Fatal(ctx, xs...)
-}
-
-// FatalErr combines Fatal and Error.
-func FatalErr(ctx context.Context, err error, xs ...Fer) {
- DefaultLogger.FatalErr(ctx, err, xs...)
-}
diff --git a/vendor/github.com/Xe/ln/stack.go b/vendor/github.com/Xe/ln/stack.go
deleted file mode 100644
index 1cf1e7a..0000000
--- a/vendor/github.com/Xe/ln/stack.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package ln
-
-import (
- "os"
- "runtime"
- "strings"
-)
-
-type frame struct {
- filename string
- function string
- lineno int
-}
-
-// skips 2 frames, since Caller returns the current frame, and we need
-// the caller's caller.
-func callersFrame() frame {
- var out frame
- pc, file, line, ok := runtime.Caller(3)
- if !ok {
- return out
- }
- srcLoc := strings.LastIndex(file, "/src/")
- if srcLoc >= 0 {
- file = file[srcLoc+5:]
- }
- out.filename = file
- out.function = functionName(pc)
- out.lineno = line
-
- return out
-}
-
-func functionName(pc uintptr) string {
- fn := runtime.FuncForPC(pc)
- if fn == nil {
- return "???"
- }
- name := fn.Name()
- beg := strings.LastIndex(name, string(os.PathSeparator))
- return name[beg+1:]
- // end := strings.LastIndex(name, string(os.PathSeparator))
- // return name[end+1 : len(name)]
-}