This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use stdout for info and debug Use stderr for warn, error, fatal and panic
- Loading branch information
1 parent
e73158f
commit df84f9a
Showing
68 changed files
with
10,795 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
package logrus | ||
|
||
import ( | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
var ( | ||
// used for debug, info, warn | ||
stdOut = log.New() | ||
// used for error, fatal, panic | ||
stdError = log.New() | ||
) | ||
|
||
// SetLogLevel sets level for both loggers | ||
func SetLogLevel(level log.Level) { | ||
stdOut.Out = os.Stdout | ||
stdError.Out = os.Stderr | ||
// used only for levels >= log.InfoLevel | ||
stdOut.SetLevel(level) | ||
// used only for levels <= log.ErrorLevel | ||
stdError.SetLevel(level) | ||
} | ||
|
||
// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key. | ||
func WithError(err error) *log.Entry { | ||
return stdError.WithField(log.ErrorKey, err) | ||
} | ||
|
||
// WithField creates an entry from the standard logger and adds a field to | ||
// it. If you want multiple fields, use `WithFields`. | ||
// | ||
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal | ||
// or Panic on the Entry it returns. | ||
func WithField(key string, value interface{}) *log.Entry { | ||
return stdOut.WithField(key, value) | ||
} | ||
|
||
// WithFields creates an entry from the standard logger and adds multiple | ||
// fields to it. This is simply a helper for `WithField`, invoking it | ||
// once for each field. | ||
// | ||
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal | ||
// or Panic on the Entry it returns. | ||
func WithFields(fields log.Fields) *log.Entry { | ||
return stdOut.WithFields(fields) | ||
} | ||
|
||
// Debug logs a message at level Debug on the standard logger. | ||
func Debug(args ...interface{}) { | ||
stdOut.Debug(args...) | ||
} | ||
|
||
// Print logs a message at level Info on the standard logger. | ||
func Print(args ...interface{}) { | ||
stdOut.Print(args...) | ||
} | ||
|
||
// Info logs a message at level Info on the standard logger. | ||
func Info(args ...interface{}) { | ||
stdOut.Info(args...) | ||
} | ||
|
||
// Warn logs a message at level Warn on the standard logger. | ||
func Warn(args ...interface{}) { | ||
stdError.Warn(args...) | ||
} | ||
|
||
// Warning logs a message at level Warn on the standard logger. | ||
func Warning(args ...interface{}) { | ||
stdError.Warning(args...) | ||
} | ||
|
||
// Error logs a message at level Error on the standard logger. | ||
func Error(args ...interface{}) { | ||
stdError.Error(args...) | ||
} | ||
|
||
// Panic logs a message at level Panic on the standard logger. | ||
func Panic(args ...interface{}) { | ||
stdError.Panic(args...) | ||
} | ||
|
||
// Fatal logs a message at level Fatal on the standard logger. | ||
func Fatal(args ...interface{}) { | ||
stdError.Fatal(args...) | ||
} | ||
|
||
// Debugf logs a message at level Debug on the standard logger. | ||
func Debugf(format string, args ...interface{}) { | ||
stdOut.Debugf(format, args...) | ||
} | ||
|
||
// Printf logs a message at level Info on the standard logger. | ||
func Printf(format string, args ...interface{}) { | ||
stdOut.Printf(format, args...) | ||
} | ||
|
||
// Infof logs a message at level Info on the standard logger. | ||
func Infof(format string, args ...interface{}) { | ||
stdOut.Infof(format, args...) | ||
} | ||
|
||
// Warnf logs a message at level Warn on the standard logger. | ||
func Warnf(format string, args ...interface{}) { | ||
stdError.Warnf(format, args...) | ||
} | ||
|
||
// Warningf logs a message at level Warn on the standard logger. | ||
func Warningf(format string, args ...interface{}) { | ||
stdError.Warningf(format, args...) | ||
} | ||
|
||
// Errorf logs a message at level Error on the standard logger. | ||
func Errorf(format string, args ...interface{}) { | ||
stdError.Errorf(format, args...) | ||
} | ||
|
||
// Panicf logs a message at level Panic on the standard logger. | ||
func Panicf(format string, args ...interface{}) { | ||
stdError.Panicf(format, args...) | ||
} | ||
|
||
// Fatalf logs a message at level Fatal on the standard logger. | ||
func Fatalf(format string, args ...interface{}) { | ||
stdError.Fatalf(format, args...) | ||
} | ||
|
||
// Debugln logs a message at level Debug on the standard logger. | ||
func Debugln(args ...interface{}) { | ||
stdOut.Debugln(args...) | ||
} | ||
|
||
// Println logs a message at level Info on the standard logger. | ||
func Println(args ...interface{}) { | ||
stdOut.Println(args...) | ||
} | ||
|
||
// Infoln logs a message at level Info on the standard logger. | ||
func Infoln(args ...interface{}) { | ||
stdOut.Infoln(args...) | ||
} | ||
|
||
// Warnln logs a message at level Warn on the standard logger. | ||
func Warnln(args ...interface{}) { | ||
stdError.Warnln(args...) | ||
} | ||
|
||
// Warningln logs a message at level Warn on the standard logger. | ||
func Warningln(args ...interface{}) { | ||
stdError.Warningln(args...) | ||
} | ||
|
||
// Errorln logs a message at level Error on the standard logger. | ||
func Errorln(args ...interface{}) { | ||
stdError.Errorln(args...) | ||
} | ||
|
||
// Panicln logs a message at level Panic on the standard logger. | ||
func Panicln(args ...interface{}) { | ||
stdError.Panicln(args...) | ||
} | ||
|
||
// Fatalln logs a message at level Fatal on the standard logger. | ||
func Fatalln(args ...interface{}) { | ||
stdError.Fatalln(args...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.