Update server dependencies
This commit is contained in:
parent
fb8fec38ff
commit
de36fe682a
883 changed files with 147940 additions and 68404 deletions
2
vendor/github.com/spf13/jwalterweatherman/README.md
generated
vendored
2
vendor/github.com/spf13/jwalterweatherman/README.md
generated
vendored
|
@ -144,5 +144,5 @@ This is an early release. I’ve been using it for a while and this is the
|
|||
third interface I’ve tried. I like this one pretty well, but no guarantees
|
||||
that it won’t change a bit.
|
||||
|
||||
I wrote this for use in [hugo](http://hugo.spf13.com). If you are looking
|
||||
I wrote this for use in [hugo](https://gohugo.io). If you are looking
|
||||
for a static website engine that’s super fast please checkout Hugo.
|
||||
|
|
1
vendor/github.com/spf13/jwalterweatherman/log_counter.go
generated
vendored
1
vendor/github.com/spf13/jwalterweatherman/log_counter.go
generated
vendored
|
@ -27,7 +27,6 @@ func (c *logCounter) getCount() uint64 {
|
|||
|
||||
func (c *logCounter) Write(p []byte) (n int, err error) {
|
||||
c.incr()
|
||||
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
|
|
93
vendor/github.com/spf13/jwalterweatherman/notepad.go
generated
vendored
93
vendor/github.com/spf13/jwalterweatherman/notepad.go
generated
vendored
|
@ -9,7 +9,6 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Threshold int
|
||||
|
@ -38,11 +37,7 @@ var prefixes map[Threshold]string = map[Threshold]string{
|
|||
LevelFatal: "FATAL",
|
||||
}
|
||||
|
||||
func prefix(t Threshold) string {
|
||||
return t.String() + " "
|
||||
}
|
||||
|
||||
// Notepad is where you leave a note !
|
||||
// Notepad is where you leave a note!
|
||||
type Notepad struct {
|
||||
TRACE *log.Logger
|
||||
DEBUG *log.Logger
|
||||
|
@ -55,7 +50,7 @@ type Notepad struct {
|
|||
LOG *log.Logger
|
||||
FEEDBACK *Feedback
|
||||
|
||||
loggers []**log.Logger
|
||||
loggers [7]**log.Logger
|
||||
logHandle io.Writer
|
||||
outHandle io.Writer
|
||||
logThreshold Threshold
|
||||
|
@ -71,11 +66,11 @@ type Notepad struct {
|
|||
func NewNotepad(outThreshold Threshold, logThreshold Threshold, outHandle, logHandle io.Writer, prefix string, flags int) *Notepad {
|
||||
n := &Notepad{}
|
||||
|
||||
n.loggers = append(n.loggers, &n.TRACE, &n.DEBUG, &n.INFO, &n.WARN, &n.ERROR, &n.CRITICAL, &n.FATAL)
|
||||
n.logHandle = logHandle
|
||||
n.loggers = [7]**log.Logger{&n.TRACE, &n.DEBUG, &n.INFO, &n.WARN, &n.ERROR, &n.CRITICAL, &n.FATAL}
|
||||
n.outHandle = outHandle
|
||||
n.logThreshold = logThreshold
|
||||
n.logHandle = logHandle
|
||||
n.stdoutThreshold = outThreshold
|
||||
n.logThreshold = logThreshold
|
||||
|
||||
if len(prefix) != 0 {
|
||||
n.prefix = "[" + prefix + "] "
|
||||
|
@ -88,54 +83,48 @@ func NewNotepad(outThreshold Threshold, logThreshold Threshold, outHandle, logHa
|
|||
n.LOG = log.New(n.logHandle,
|
||||
"LOG: ",
|
||||
n.flags)
|
||||
|
||||
n.FEEDBACK = &Feedback{n}
|
||||
n.FEEDBACK = &Feedback{out: log.New(outHandle, "", 0), log: n.LOG}
|
||||
|
||||
n.init()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
// Feedback is special. It writes plainly to the output while
|
||||
// logging with the standard extra information (date, file, etc)
|
||||
// Only Println and Printf are currently provided for this
|
||||
type Feedback struct {
|
||||
*Notepad
|
||||
}
|
||||
|
||||
// init create the loggers for each level depending on the notepad thresholds
|
||||
// init creates the loggers for each level depending on the notepad thresholds.
|
||||
func (n *Notepad) init() {
|
||||
bothHandle := io.MultiWriter(n.outHandle, n.logHandle)
|
||||
logAndOut := io.MultiWriter(n.outHandle, n.logHandle)
|
||||
|
||||
for t, logger := range n.loggers {
|
||||
threshold := Threshold(t)
|
||||
counter := &logCounter{}
|
||||
n.logCounters[t] = counter
|
||||
prefix := n.prefix + threshold.String() + " "
|
||||
|
||||
switch {
|
||||
case threshold >= n.logThreshold && threshold >= n.stdoutThreshold:
|
||||
*logger = log.New(io.MultiWriter(counter, bothHandle), n.prefix+prefix(threshold), n.flags)
|
||||
*logger = log.New(io.MultiWriter(counter, logAndOut), prefix, n.flags)
|
||||
|
||||
case threshold >= n.logThreshold:
|
||||
*logger = log.New(io.MultiWriter(counter, n.logHandle), n.prefix+prefix(threshold), n.flags)
|
||||
*logger = log.New(io.MultiWriter(counter, n.logHandle), prefix, n.flags)
|
||||
|
||||
case threshold >= n.stdoutThreshold:
|
||||
*logger = log.New(io.MultiWriter(counter, os.Stdout), n.prefix+prefix(threshold), n.flags)
|
||||
*logger = log.New(io.MultiWriter(counter, n.outHandle), prefix, n.flags)
|
||||
|
||||
default:
|
||||
*logger = log.New(counter, n.prefix+prefix(threshold), n.flags)
|
||||
// counter doesn't care about prefix and flags, so don't use them
|
||||
// for performance.
|
||||
*logger = log.New(counter, "", 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetLogThreshold change the threshold above which messages are written to the
|
||||
// log file
|
||||
// SetLogThreshold changes the threshold above which messages are written to the
|
||||
// log file.
|
||||
func (n *Notepad) SetLogThreshold(threshold Threshold) {
|
||||
n.logThreshold = threshold
|
||||
n.init()
|
||||
}
|
||||
|
||||
// SetLogOutput change the file where log messages are written
|
||||
// SetLogOutput changes the file where log messages are written.
|
||||
func (n *Notepad) SetLogOutput(handle io.Writer) {
|
||||
n.logHandle = handle
|
||||
n.init()
|
||||
|
@ -146,8 +135,8 @@ func (n *Notepad) GetLogThreshold() Threshold {
|
|||
return n.logThreshold
|
||||
}
|
||||
|
||||
// SetStdoutThreshold change the threshold above which messages are written to the
|
||||
// standard output
|
||||
// SetStdoutThreshold changes the threshold above which messages are written to the
|
||||
// standard output.
|
||||
func (n *Notepad) SetStdoutThreshold(threshold Threshold) {
|
||||
n.stdoutThreshold = threshold
|
||||
n.init()
|
||||
|
@ -158,8 +147,8 @@ func (n *Notepad) GetStdoutThreshold() Threshold {
|
|||
return n.stdoutThreshold
|
||||
}
|
||||
|
||||
// SetPrefix change the prefix used by the notepad. Prefixes are displayed between
|
||||
// brackets at the begining of the line. An empty prefix won't be displayed at all.
|
||||
// SetPrefix changes the prefix used by the notepad. Prefixes are displayed between
|
||||
// brackets at the beginning of the line. An empty prefix won't be displayed at all.
|
||||
func (n *Notepad) SetPrefix(prefix string) {
|
||||
if len(prefix) != 0 {
|
||||
n.prefix = "[" + prefix + "] "
|
||||
|
@ -176,20 +165,30 @@ func (n *Notepad) SetFlags(flags int) {
|
|||
n.init()
|
||||
}
|
||||
|
||||
// Feedback is special. It writes plainly to the output while
|
||||
// logging with the standard extra information (date, file, etc)
|
||||
// Only Println and Printf are currently provided for this
|
||||
func (fb *Feedback) Println(v ...interface{}) {
|
||||
s := fmt.Sprintln(v...)
|
||||
fmt.Print(s)
|
||||
fb.LOG.Output(2, s)
|
||||
// Feedback writes plainly to the outHandle while
|
||||
// logging with the standard extra information (date, file, etc).
|
||||
type Feedback struct {
|
||||
out *log.Logger
|
||||
log *log.Logger
|
||||
}
|
||||
|
||||
// Feedback is special. It writes plainly to the output while
|
||||
// logging with the standard extra information (date, file, etc)
|
||||
// Only Println and Printf are currently provided for this
|
||||
func (fb *Feedback) Printf(format string, v ...interface{}) {
|
||||
s := fmt.Sprintf(format, v...)
|
||||
fmt.Print(s)
|
||||
fb.LOG.Output(2, s)
|
||||
func (fb *Feedback) Println(v ...interface{}) {
|
||||
fb.output(fmt.Sprintln(v...))
|
||||
}
|
||||
|
||||
func (fb *Feedback) Printf(format string, v ...interface{}) {
|
||||
fb.output(fmt.Sprintf(format, v...))
|
||||
}
|
||||
|
||||
func (fb *Feedback) Print(v ...interface{}) {
|
||||
fb.output(fmt.Sprint(v...))
|
||||
}
|
||||
|
||||
func (fb *Feedback) output(s string) {
|
||||
if fb.out != nil {
|
||||
fb.out.Output(2, s)
|
||||
}
|
||||
if fb.log != nil {
|
||||
fb.log.Output(2, s)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue