mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-05 00:04:04 +00:00
Update dependencies (#1610)
* Update dependencies * Update module to go 1.17
This commit is contained in:
1
vendor/github.com/apex/log/.gitignore
generated
vendored
Normal file
1
vendor/github.com/apex/log/.gitignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
.envrc
|
75
vendor/github.com/apex/log/History.md
generated
vendored
Normal file
75
vendor/github.com/apex/log/History.md
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
v1.9.0 / 2020-08-18
|
||||
===================
|
||||
|
||||
* add `WithDuration()` method to record a duration as milliseconds
|
||||
* add: ignore nil errors in `WithError()`
|
||||
* change trace duration to milliseconds (arguably a breaking change)
|
||||
|
||||
v1.8.0 / 2020-08-05
|
||||
===================
|
||||
|
||||
* refactor apexlogs handler to not make the AddEvents() call if there are no events to flush
|
||||
|
||||
v1.7.1 / 2020-08-05
|
||||
===================
|
||||
|
||||
* fix potential nil panic in apexlogs handler
|
||||
|
||||
v1.7.0 / 2020-08-03
|
||||
===================
|
||||
|
||||
* add FlushSync() to apexlogs handler
|
||||
|
||||
v1.6.0 / 2020-07-13
|
||||
===================
|
||||
|
||||
* update apex/logs dep to v1.0.0
|
||||
* docs: mention that Flush() is non-blocking now, use Close()
|
||||
|
||||
v1.5.0 / 2020-07-11
|
||||
===================
|
||||
|
||||
* add buffering to Apex Logs handler
|
||||
|
||||
v1.4.0 / 2020-06-16
|
||||
===================
|
||||
|
||||
* add AuthToken to apexlogs handler
|
||||
|
||||
v1.3.0 / 2020-05-26
|
||||
===================
|
||||
|
||||
* change FromContext() to always return a logger
|
||||
|
||||
v1.2.0 / 2020-05-26
|
||||
===================
|
||||
|
||||
* add log.NewContext() and log.FromContext(). Closes #78
|
||||
|
||||
v1.1.4 / 2020-04-22
|
||||
===================
|
||||
|
||||
* add apexlogs HTTPClient support
|
||||
|
||||
v1.1.3 / 2020-04-22
|
||||
===================
|
||||
|
||||
* add events len check before flushing to apexlogs handler
|
||||
|
||||
v1.1.2 / 2020-01-29
|
||||
===================
|
||||
|
||||
* refactor apexlogs handler to use github.com/apex/logs client
|
||||
|
||||
v1.1.1 / 2019-06-24
|
||||
===================
|
||||
|
||||
* add go.mod
|
||||
* add rough pass at apexlogs handler
|
||||
|
||||
v1.1.0 / 2018-10-11
|
||||
===================
|
||||
|
||||
* fix: cli handler to show non-string fields appropriately
|
||||
* fix: cli using fatih/color to better support windows
|
22
vendor/github.com/apex/log/LICENSE
generated
vendored
Normal file
22
vendor/github.com/apex/log/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 TJ Holowaychuk tj@tjholowaychuk.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2
vendor/github.com/apex/log/Makefile
generated
vendored
Normal file
2
vendor/github.com/apex/log/Makefile
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
include github.com/tj/make/golang
|
61
vendor/github.com/apex/log/Readme.md
generated
vendored
Normal file
61
vendor/github.com/apex/log/Readme.md
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||

|
||||
|
||||
Package log implements a simple structured logging API inspired by Logrus, designed with centralization in mind. Read more on [Medium](https://medium.com/@tjholowaychuk/apex-log-e8d9627f4a9a#.rav8yhkud).
|
||||
|
||||
## Handlers
|
||||
|
||||
- __apexlogs__ – handler for [Apex Logs](https://apex.sh/logs/)
|
||||
- __cli__ – human-friendly CLI output
|
||||
- __discard__ – discards all logs
|
||||
- __es__ – Elasticsearch handler
|
||||
- __graylog__ – Graylog handler
|
||||
- __json__ – JSON output handler
|
||||
- __kinesis__ – AWS Kinesis handler
|
||||
- __level__ – level filter handler
|
||||
- __logfmt__ – logfmt plain-text formatter
|
||||
- __memory__ – in-memory handler for tests
|
||||
- __multi__ – fan-out to multiple handlers
|
||||
- __papertrail__ – Papertrail handler
|
||||
- __text__ – human-friendly colored output
|
||||
- __delta__ – outputs the delta between log calls and spinner
|
||||
|
||||
## Example
|
||||
|
||||
Example using the [Apex Logs](https://apex.sh/logs/) handler.
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/apex/log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := log.WithFields(log.Fields{
|
||||
"file": "something.png",
|
||||
"type": "image/png",
|
||||
"user": "tobi",
|
||||
})
|
||||
|
||||
for range time.Tick(time.Millisecond * 200) {
|
||||
ctx.Info("upload")
|
||||
ctx.Info("upload complete")
|
||||
ctx.Warn("upload retry")
|
||||
ctx.WithError(errors.New("unauthorized")).Error("upload failed")
|
||||
ctx.Errorf("failed to upload %s", "img.png")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
[](https://semaphoreci.com/tj/log)
|
||||
[](https://godoc.org/github.com/apex/log)
|
||||

|
||||

|
||||
|
||||
<a href="https://apex.sh"><img src="http://tjholowaychuk.com:6000/svg/sponsor"></a>
|
19
vendor/github.com/apex/log/context.go
generated
vendored
Normal file
19
vendor/github.com/apex/log/context.go
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
package log
|
||||
|
||||
import "context"
|
||||
|
||||
// logKey is a private context key.
|
||||
type logKey struct{}
|
||||
|
||||
// NewContext returns a new context with logger.
|
||||
func NewContext(ctx context.Context, v Interface) context.Context {
|
||||
return context.WithValue(ctx, logKey{}, v)
|
||||
}
|
||||
|
||||
// FromContext returns the logger from context, or log.Log.
|
||||
func FromContext(ctx context.Context) Interface {
|
||||
if v, ok := ctx.Value(logKey{}).(Interface); ok {
|
||||
return v
|
||||
}
|
||||
return Log
|
||||
}
|
45
vendor/github.com/apex/log/default.go
generated
vendored
Normal file
45
vendor/github.com/apex/log/default.go
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// field used for sorting.
|
||||
type field struct {
|
||||
Name string
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
// by sorts fields by name.
|
||||
type byName []field
|
||||
|
||||
func (a byName) Len() int { return len(a) }
|
||||
func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a byName) Less(i, j int) bool { return a[i].Name < a[j].Name }
|
||||
|
||||
// handleStdLog outpouts to the stlib log.
|
||||
func handleStdLog(e *Entry) error {
|
||||
level := levelNames[e.Level]
|
||||
|
||||
var fields []field
|
||||
|
||||
for k, v := range e.Fields {
|
||||
fields = append(fields, field{k, v})
|
||||
}
|
||||
|
||||
sort.Sort(byName(fields))
|
||||
|
||||
var b bytes.Buffer
|
||||
fmt.Fprintf(&b, "%5s %-25s", level, e.Message)
|
||||
|
||||
for _, f := range fields {
|
||||
fmt.Fprintf(&b, " %s=%v", f.Name, f.Value)
|
||||
}
|
||||
|
||||
log.Println(b.String())
|
||||
|
||||
return nil
|
||||
}
|
10
vendor/github.com/apex/log/doc.go
generated
vendored
Normal file
10
vendor/github.com/apex/log/doc.go
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
Package log implements a simple structured logging API designed with few assumptions. Designed for
|
||||
centralized logging solutions such as Kinesis which require encoding and decoding before fanning-out
|
||||
to handlers.
|
||||
|
||||
You may use this package with inline handlers, much like Logrus, however a centralized solution
|
||||
is recommended so that apps do not need to be re-deployed to add or remove logging service
|
||||
providers.
|
||||
*/
|
||||
package log
|
182
vendor/github.com/apex/log/entry.go
generated
vendored
Normal file
182
vendor/github.com/apex/log/entry.go
generated
vendored
Normal file
@ -0,0 +1,182 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// assert interface compliance.
|
||||
var _ Interface = (*Entry)(nil)
|
||||
|
||||
// Now returns the current time.
|
||||
var Now = time.Now
|
||||
|
||||
// Entry represents a single log entry.
|
||||
type Entry struct {
|
||||
Logger *Logger `json:"-"`
|
||||
Fields Fields `json:"fields"`
|
||||
Level Level `json:"level"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Message string `json:"message"`
|
||||
start time.Time
|
||||
fields []Fields
|
||||
}
|
||||
|
||||
// NewEntry returns a new entry for `log`.
|
||||
func NewEntry(log *Logger) *Entry {
|
||||
return &Entry{
|
||||
Logger: log,
|
||||
}
|
||||
}
|
||||
|
||||
// WithFields returns a new entry with `fields` set.
|
||||
func (e *Entry) WithFields(fields Fielder) *Entry {
|
||||
f := []Fields{}
|
||||
f = append(f, e.fields...)
|
||||
f = append(f, fields.Fields())
|
||||
return &Entry{
|
||||
Logger: e.Logger,
|
||||
fields: f,
|
||||
}
|
||||
}
|
||||
|
||||
// WithField returns a new entry with the `key` and `value` set.
|
||||
func (e *Entry) WithField(key string, value interface{}) *Entry {
|
||||
return e.WithFields(Fields{key: value})
|
||||
}
|
||||
|
||||
// WithDuration returns a new entry with the "duration" field set
|
||||
// to the given duration in milliseconds.
|
||||
func (e *Entry) WithDuration(d time.Duration) *Entry {
|
||||
return e.WithField("duration", d.Milliseconds())
|
||||
}
|
||||
|
||||
// WithError returns a new entry with the "error" set to `err`.
|
||||
//
|
||||
// The given error may implement .Fielder, if it does the method
|
||||
// will add all its `.Fields()` into the returned entry.
|
||||
func (e *Entry) WithError(err error) *Entry {
|
||||
if err == nil {
|
||||
return e
|
||||
}
|
||||
|
||||
ctx := e.WithField("error", err.Error())
|
||||
|
||||
if s, ok := err.(stackTracer); ok {
|
||||
frame := s.StackTrace()[0]
|
||||
|
||||
name := fmt.Sprintf("%n", frame)
|
||||
file := fmt.Sprintf("%+s", frame)
|
||||
line := fmt.Sprintf("%d", frame)
|
||||
|
||||
parts := strings.Split(file, "\n\t")
|
||||
if len(parts) > 1 {
|
||||
file = parts[1]
|
||||
}
|
||||
|
||||
ctx = ctx.WithField("source", fmt.Sprintf("%s: %s:%s", name, file, line))
|
||||
}
|
||||
|
||||
if f, ok := err.(Fielder); ok {
|
||||
ctx = ctx.WithFields(f.Fields())
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
// Debug level message.
|
||||
func (e *Entry) Debug(msg string) {
|
||||
e.Logger.log(DebugLevel, e, msg)
|
||||
}
|
||||
|
||||
// Info level message.
|
||||
func (e *Entry) Info(msg string) {
|
||||
e.Logger.log(InfoLevel, e, msg)
|
||||
}
|
||||
|
||||
// Warn level message.
|
||||
func (e *Entry) Warn(msg string) {
|
||||
e.Logger.log(WarnLevel, e, msg)
|
||||
}
|
||||
|
||||
// Error level message.
|
||||
func (e *Entry) Error(msg string) {
|
||||
e.Logger.log(ErrorLevel, e, msg)
|
||||
}
|
||||
|
||||
// Fatal level message, followed by an exit.
|
||||
func (e *Entry) Fatal(msg string) {
|
||||
e.Logger.log(FatalLevel, e, msg)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Debugf level formatted message.
|
||||
func (e *Entry) Debugf(msg string, v ...interface{}) {
|
||||
e.Debug(fmt.Sprintf(msg, v...))
|
||||
}
|
||||
|
||||
// Infof level formatted message.
|
||||
func (e *Entry) Infof(msg string, v ...interface{}) {
|
||||
e.Info(fmt.Sprintf(msg, v...))
|
||||
}
|
||||
|
||||
// Warnf level formatted message.
|
||||
func (e *Entry) Warnf(msg string, v ...interface{}) {
|
||||
e.Warn(fmt.Sprintf(msg, v...))
|
||||
}
|
||||
|
||||
// Errorf level formatted message.
|
||||
func (e *Entry) Errorf(msg string, v ...interface{}) {
|
||||
e.Error(fmt.Sprintf(msg, v...))
|
||||
}
|
||||
|
||||
// Fatalf level formatted message, followed by an exit.
|
||||
func (e *Entry) Fatalf(msg string, v ...interface{}) {
|
||||
e.Fatal(fmt.Sprintf(msg, v...))
|
||||
}
|
||||
|
||||
// Trace returns a new entry with a Stop method to fire off
|
||||
// a corresponding completion log, useful with defer.
|
||||
func (e *Entry) Trace(msg string) *Entry {
|
||||
e.Info(msg)
|
||||
v := e.WithFields(e.Fields)
|
||||
v.Message = msg
|
||||
v.start = time.Now()
|
||||
return v
|
||||
}
|
||||
|
||||
// Stop should be used with Trace, to fire off the completion message. When
|
||||
// an `err` is passed the "error" field is set, and the log level is error.
|
||||
func (e *Entry) Stop(err *error) {
|
||||
if err == nil || *err == nil {
|
||||
e.WithDuration(time.Since(e.start)).Info(e.Message)
|
||||
} else {
|
||||
e.WithDuration(time.Since(e.start)).WithError(*err).Error(e.Message)
|
||||
}
|
||||
}
|
||||
|
||||
// mergedFields returns the fields list collapsed into a single map.
|
||||
func (e *Entry) mergedFields() Fields {
|
||||
f := Fields{}
|
||||
|
||||
for _, fields := range e.fields {
|
||||
for k, v := range fields {
|
||||
f[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
// finalize returns a copy of the Entry with Fields merged.
|
||||
func (e *Entry) finalize(level Level, msg string) *Entry {
|
||||
return &Entry{
|
||||
Logger: e.Logger,
|
||||
Fields: e.mergedFields(),
|
||||
Level: level,
|
||||
Message: msg,
|
||||
Timestamp: Now(),
|
||||
}
|
||||
}
|
22
vendor/github.com/apex/log/interface.go
generated
vendored
Normal file
22
vendor/github.com/apex/log/interface.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
package log
|
||||
|
||||
import "time"
|
||||
|
||||
// Interface represents the API of both Logger and Entry.
|
||||
type Interface interface {
|
||||
WithFields(Fielder) *Entry
|
||||
WithField(string, interface{}) *Entry
|
||||
WithDuration(time.Duration) *Entry
|
||||
WithError(error) *Entry
|
||||
Debug(string)
|
||||
Info(string)
|
||||
Warn(string)
|
||||
Error(string)
|
||||
Fatal(string)
|
||||
Debugf(string, ...interface{})
|
||||
Infof(string, ...interface{})
|
||||
Warnf(string, ...interface{})
|
||||
Errorf(string, ...interface{})
|
||||
Fatalf(string, ...interface{})
|
||||
Trace(string) *Entry
|
||||
}
|
81
vendor/github.com/apex/log/levels.go
generated
vendored
Normal file
81
vendor/github.com/apex/log/levels.go
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ErrInvalidLevel is returned if the severity level is invalid.
|
||||
var ErrInvalidLevel = errors.New("invalid level")
|
||||
|
||||
// Level of severity.
|
||||
type Level int
|
||||
|
||||
// Log levels.
|
||||
const (
|
||||
InvalidLevel Level = iota - 1
|
||||
DebugLevel
|
||||
InfoLevel
|
||||
WarnLevel
|
||||
ErrorLevel
|
||||
FatalLevel
|
||||
)
|
||||
|
||||
var levelNames = [...]string{
|
||||
DebugLevel: "debug",
|
||||
InfoLevel: "info",
|
||||
WarnLevel: "warn",
|
||||
ErrorLevel: "error",
|
||||
FatalLevel: "fatal",
|
||||
}
|
||||
|
||||
var levelStrings = map[string]Level{
|
||||
"debug": DebugLevel,
|
||||
"info": InfoLevel,
|
||||
"warn": WarnLevel,
|
||||
"warning": WarnLevel,
|
||||
"error": ErrorLevel,
|
||||
"fatal": FatalLevel,
|
||||
}
|
||||
|
||||
// String implementation.
|
||||
func (l Level) String() string {
|
||||
return levelNames[l]
|
||||
}
|
||||
|
||||
// MarshalJSON implementation.
|
||||
func (l Level) MarshalJSON() ([]byte, error) {
|
||||
return []byte(`"` + l.String() + `"`), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implementation.
|
||||
func (l *Level) UnmarshalJSON(b []byte) error {
|
||||
v, err := ParseLevel(string(bytes.Trim(b, `"`)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*l = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseLevel parses level string.
|
||||
func ParseLevel(s string) (Level, error) {
|
||||
l, ok := levelStrings[strings.ToLower(s)]
|
||||
if !ok {
|
||||
return InvalidLevel, ErrInvalidLevel
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
||||
|
||||
// MustParseLevel parses level string or panics.
|
||||
func MustParseLevel(s string) Level {
|
||||
l, err := ParseLevel(s)
|
||||
if err != nil {
|
||||
panic("invalid log level")
|
||||
}
|
||||
|
||||
return l
|
||||
}
|
156
vendor/github.com/apex/log/logger.go
generated
vendored
Normal file
156
vendor/github.com/apex/log/logger.go
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
stdlog "log"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
// assert interface compliance.
|
||||
var _ Interface = (*Logger)(nil)
|
||||
|
||||
// Fielder is an interface for providing fields to custom types.
|
||||
type Fielder interface {
|
||||
Fields() Fields
|
||||
}
|
||||
|
||||
// Fields represents a map of entry level data used for structured logging.
|
||||
type Fields map[string]interface{}
|
||||
|
||||
// Fields implements Fielder.
|
||||
func (f Fields) Fields() Fields {
|
||||
return f
|
||||
}
|
||||
|
||||
// Get field value by name.
|
||||
func (f Fields) Get(name string) interface{} {
|
||||
return f[name]
|
||||
}
|
||||
|
||||
// Names returns field names sorted.
|
||||
func (f Fields) Names() (v []string) {
|
||||
for k := range f {
|
||||
v = append(v, k)
|
||||
}
|
||||
|
||||
sort.Strings(v)
|
||||
return
|
||||
}
|
||||
|
||||
// The HandlerFunc type is an adapter to allow the use of ordinary functions as
|
||||
// log handlers. If f is a function with the appropriate signature,
|
||||
// HandlerFunc(f) is a Handler object that calls f.
|
||||
type HandlerFunc func(*Entry) error
|
||||
|
||||
// HandleLog calls f(e).
|
||||
func (f HandlerFunc) HandleLog(e *Entry) error {
|
||||
return f(e)
|
||||
}
|
||||
|
||||
// Handler is used to handle log events, outputting them to
|
||||
// stdio or sending them to remote services. See the "handlers"
|
||||
// directory for implementations.
|
||||
//
|
||||
// It is left up to Handlers to implement thread-safety.
|
||||
type Handler interface {
|
||||
HandleLog(*Entry) error
|
||||
}
|
||||
|
||||
// Logger represents a logger with configurable Level and Handler.
|
||||
type Logger struct {
|
||||
Handler Handler
|
||||
Level Level
|
||||
}
|
||||
|
||||
// WithFields returns a new entry with `fields` set.
|
||||
func (l *Logger) WithFields(fields Fielder) *Entry {
|
||||
return NewEntry(l).WithFields(fields.Fields())
|
||||
}
|
||||
|
||||
// WithField returns a new entry with the `key` and `value` set.
|
||||
//
|
||||
// Note that the `key` should not have spaces in it - use camel
|
||||
// case or underscores
|
||||
func (l *Logger) WithField(key string, value interface{}) *Entry {
|
||||
return NewEntry(l).WithField(key, value)
|
||||
}
|
||||
|
||||
// WithDuration returns a new entry with the "duration" field set
|
||||
// to the given duration in milliseconds.
|
||||
func (l *Logger) WithDuration(d time.Duration) *Entry {
|
||||
return NewEntry(l).WithDuration(d)
|
||||
}
|
||||
|
||||
// WithError returns a new entry with the "error" set to `err`.
|
||||
func (l *Logger) WithError(err error) *Entry {
|
||||
return NewEntry(l).WithError(err)
|
||||
}
|
||||
|
||||
// Debug level message.
|
||||
func (l *Logger) Debug(msg string) {
|
||||
NewEntry(l).Debug(msg)
|
||||
}
|
||||
|
||||
// Info level message.
|
||||
func (l *Logger) Info(msg string) {
|
||||
NewEntry(l).Info(msg)
|
||||
}
|
||||
|
||||
// Warn level message.
|
||||
func (l *Logger) Warn(msg string) {
|
||||
NewEntry(l).Warn(msg)
|
||||
}
|
||||
|
||||
// Error level message.
|
||||
func (l *Logger) Error(msg string) {
|
||||
NewEntry(l).Error(msg)
|
||||
}
|
||||
|
||||
// Fatal level message, followed by an exit.
|
||||
func (l *Logger) Fatal(msg string) {
|
||||
NewEntry(l).Fatal(msg)
|
||||
}
|
||||
|
||||
// Debugf level formatted message.
|
||||
func (l *Logger) Debugf(msg string, v ...interface{}) {
|
||||
NewEntry(l).Debugf(msg, v...)
|
||||
}
|
||||
|
||||
// Infof level formatted message.
|
||||
func (l *Logger) Infof(msg string, v ...interface{}) {
|
||||
NewEntry(l).Infof(msg, v...)
|
||||
}
|
||||
|
||||
// Warnf level formatted message.
|
||||
func (l *Logger) Warnf(msg string, v ...interface{}) {
|
||||
NewEntry(l).Warnf(msg, v...)
|
||||
}
|
||||
|
||||
// Errorf level formatted message.
|
||||
func (l *Logger) Errorf(msg string, v ...interface{}) {
|
||||
NewEntry(l).Errorf(msg, v...)
|
||||
}
|
||||
|
||||
// Fatalf level formatted message, followed by an exit.
|
||||
func (l *Logger) Fatalf(msg string, v ...interface{}) {
|
||||
NewEntry(l).Fatalf(msg, v...)
|
||||
}
|
||||
|
||||
// Trace returns a new entry with a Stop method to fire off
|
||||
// a corresponding completion log, useful with defer.
|
||||
func (l *Logger) Trace(msg string) *Entry {
|
||||
return NewEntry(l).Trace(msg)
|
||||
}
|
||||
|
||||
// log the message, invoking the handler. We clone the entry here
|
||||
// to bypass the overhead in Entry methods when the level is not
|
||||
// met.
|
||||
func (l *Logger) log(level Level, e *Entry, msg string) {
|
||||
if level < l.Level {
|
||||
return
|
||||
}
|
||||
|
||||
if err := l.Handler.HandleLog(e.finalize(level, msg)); err != nil {
|
||||
stdlog.Printf("error logging: %s", err)
|
||||
}
|
||||
}
|
108
vendor/github.com/apex/log/pkg.go
generated
vendored
Normal file
108
vendor/github.com/apex/log/pkg.go
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
package log
|
||||
|
||||
import "time"
|
||||
|
||||
// singletons ftw?
|
||||
var Log Interface = &Logger{
|
||||
Handler: HandlerFunc(handleStdLog),
|
||||
Level: InfoLevel,
|
||||
}
|
||||
|
||||
// SetHandler sets the handler. This is not thread-safe.
|
||||
// The default handler outputs to the stdlib log.
|
||||
func SetHandler(h Handler) {
|
||||
if logger, ok := Log.(*Logger); ok {
|
||||
logger.Handler = h
|
||||
}
|
||||
}
|
||||
|
||||
// SetLevel sets the log level. This is not thread-safe.
|
||||
func SetLevel(l Level) {
|
||||
if logger, ok := Log.(*Logger); ok {
|
||||
logger.Level = l
|
||||
}
|
||||
}
|
||||
|
||||
// SetLevelFromString sets the log level from a string, panicing when invalid. This is not thread-safe.
|
||||
func SetLevelFromString(s string) {
|
||||
if logger, ok := Log.(*Logger); ok {
|
||||
logger.Level = MustParseLevel(s)
|
||||
}
|
||||
}
|
||||
|
||||
// WithFields returns a new entry with `fields` set.
|
||||
func WithFields(fields Fielder) *Entry {
|
||||
return Log.WithFields(fields)
|
||||
}
|
||||
|
||||
// WithField returns a new entry with the `key` and `value` set.
|
||||
func WithField(key string, value interface{}) *Entry {
|
||||
return Log.WithField(key, value)
|
||||
}
|
||||
|
||||
// WithDuration returns a new entry with the "duration" field set
|
||||
// to the given duration in milliseconds.
|
||||
func WithDuration(d time.Duration) *Entry {
|
||||
return Log.WithDuration(d)
|
||||
}
|
||||
|
||||
// WithError returns a new entry with the "error" set to `err`.
|
||||
func WithError(err error) *Entry {
|
||||
return Log.WithError(err)
|
||||
}
|
||||
|
||||
// Debug level message.
|
||||
func Debug(msg string) {
|
||||
Log.Debug(msg)
|
||||
}
|
||||
|
||||
// Info level message.
|
||||
func Info(msg string) {
|
||||
Log.Info(msg)
|
||||
}
|
||||
|
||||
// Warn level message.
|
||||
func Warn(msg string) {
|
||||
Log.Warn(msg)
|
||||
}
|
||||
|
||||
// Error level message.
|
||||
func Error(msg string) {
|
||||
Log.Error(msg)
|
||||
}
|
||||
|
||||
// Fatal level message, followed by an exit.
|
||||
func Fatal(msg string) {
|
||||
Log.Fatal(msg)
|
||||
}
|
||||
|
||||
// Debugf level formatted message.
|
||||
func Debugf(msg string, v ...interface{}) {
|
||||
Log.Debugf(msg, v...)
|
||||
}
|
||||
|
||||
// Infof level formatted message.
|
||||
func Infof(msg string, v ...interface{}) {
|
||||
Log.Infof(msg, v...)
|
||||
}
|
||||
|
||||
// Warnf level formatted message.
|
||||
func Warnf(msg string, v ...interface{}) {
|
||||
Log.Warnf(msg, v...)
|
||||
}
|
||||
|
||||
// Errorf level formatted message.
|
||||
func Errorf(msg string, v ...interface{}) {
|
||||
Log.Errorf(msg, v...)
|
||||
}
|
||||
|
||||
// Fatalf level formatted message, followed by an exit.
|
||||
func Fatalf(msg string, v ...interface{}) {
|
||||
Log.Fatalf(msg, v...)
|
||||
}
|
||||
|
||||
// Trace returns a new entry with a Stop method to fire off
|
||||
// a corresponding completion log, useful with defer.
|
||||
func Trace(msg string) *Entry {
|
||||
return Log.Trace(msg)
|
||||
}
|
8
vendor/github.com/apex/log/stack.go
generated
vendored
Normal file
8
vendor/github.com/apex/log/stack.go
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
package log
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
|
||||
// stackTracer interface.
|
||||
type stackTracer interface {
|
||||
StackTrace() errors.StackTrace
|
||||
}
|
Reference in New Issue
Block a user