mirror of https://github.com/k3d-io/k3d
pull/226/head
commit
48f8393a86
@ -0,0 +1,40 @@ |
||||
run: |
||||
# do not run on test files yet |
||||
tests: false |
||||
|
||||
# all available settings of specific linters |
||||
linters-settings: |
||||
errcheck: |
||||
# report about not checking of errors in type assetions: `a := b.(MyStruct)`; |
||||
# default is false: such cases aren't reported by default. |
||||
check-type-assertions: false |
||||
|
||||
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; |
||||
# default is false: such cases aren't reported by default. |
||||
check-blank: false |
||||
|
||||
lll: |
||||
line-length: 100 |
||||
tab-width: 4 |
||||
|
||||
prealloc: |
||||
simple: false |
||||
range-loops: false |
||||
for-loops: false |
||||
|
||||
whitespace: |
||||
multi-if: false # Enforces newlines (or comments) after every multi-line if statement |
||||
multi-func: false # Enforces newlines (or comments) after every multi-line function signature |
||||
|
||||
linters: |
||||
enable: |
||||
- megacheck |
||||
- govet |
||||
disable: |
||||
- maligned |
||||
- prealloc |
||||
disable-all: false |
||||
presets: |
||||
- bugs |
||||
- unused |
||||
fast: false |
@ -1,16 +1,10 @@ |
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe h1:CHRGQ8V7OlCYtwaKPJi3iA7J+YdNKdo8j7nG5IgDhjs= |
||||
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= |
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= |
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= |
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= |
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= |
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= |
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= |
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= |
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
@ -0,0 +1,43 @@ |
||||
# Writer Hooks for Logrus |
||||
|
||||
Send logs of given levels to any object with `io.Writer` interface. |
||||
|
||||
## Usage |
||||
|
||||
If you want for example send high level logs to `Stderr` and |
||||
logs of normal execution to `Stdout`, you could do it like this: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import ( |
||||
"io/ioutil" |
||||
"os" |
||||
|
||||
log "github.com/sirupsen/logrus" |
||||
"github.com/sirupsen/logrus/hooks/writer" |
||||
) |
||||
|
||||
func main() { |
||||
log.SetOutput(ioutil.Discard) // Send all logs to nowhere by default |
||||
|
||||
log.AddHook(&writer.Hook{ // Send logs with level higher than warning to stderr |
||||
Writer: os.Stderr, |
||||
LogLevels: []log.Level{ |
||||
log.PanicLevel, |
||||
log.FatalLevel, |
||||
log.ErrorLevel, |
||||
log.WarnLevel, |
||||
}, |
||||
}) |
||||
log.AddHook(&writer.Hook{ // Send info and debug logs to stdout |
||||
Writer: os.Stdout, |
||||
LogLevels: []log.Level{ |
||||
log.InfoLevel, |
||||
log.DebugLevel, |
||||
}, |
||||
}) |
||||
log.Info("This will go to stdout") |
||||
log.Warn("This will go to stderr") |
||||
} |
||||
``` |
@ -0,0 +1,29 @@ |
||||
package writer |
||||
|
||||
import ( |
||||
"io" |
||||
|
||||
log "github.com/sirupsen/logrus" |
||||
) |
||||
|
||||
// Hook is a hook that writes logs of specified LogLevels to specified Writer
|
||||
type Hook struct { |
||||
Writer io.Writer |
||||
LogLevels []log.Level |
||||
} |
||||
|
||||
// Fire will be called when some logging function is called with current hook
|
||||
// It will format log entry to string and write it to appropriate writer
|
||||
func (hook *Hook) Fire(entry *log.Entry) error { |
||||
line, err := entry.Bytes() |
||||
if err != nil { |
||||
return err |
||||
} |
||||
_, err = hook.Writer.Write(line) |
||||
return err |
||||
} |
||||
|
||||
// Levels define on which log levels this hook would trigger
|
||||
func (hook *Hook) Levels() []log.Level { |
||||
return hook.LogLevels |
||||
} |
@ -0,0 +1,7 @@ |
||||
// +build js
|
||||
|
||||
package logrus |
||||
|
||||
func isTerminal(fd int) bool { |
||||
return false |
||||
} |
Loading…
Reference in new issue