Documentation ¶
Overview ¶
Package logger provides methods and interfaces used by other stash packages for logging purposes.
Index ¶
- Variables
- func Debug(args ...interface{})
- func DebugFunc(fn func() (string, []interface{}))
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func ErrorFunc(fn func() (string, []interface{}))
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Info(args ...interface{})
- func InfoFunc(fn func() (string, []interface{}))
- func Infof(format string, args ...interface{})
- func Progressf(format string, args ...interface{})
- func Trace(args ...interface{})
- func TraceFunc(fn func() (string, []interface{}))
- func Tracef(format string, args ...interface{})
- func Warn(args ...interface{})
- func WarnFunc(fn func() (string, []interface{}))
- func Warnf(format string, args ...interface{})
- type BasicLogger
- func (log *BasicLogger) Debug(args ...interface{})
- func (log *BasicLogger) DebugFunc(fn func() (string, []interface{}))
- func (log *BasicLogger) Debugf(format string, args ...interface{})
- func (log *BasicLogger) Error(args ...interface{})
- func (log *BasicLogger) ErrorFunc(fn func() (string, []interface{}))
- func (log *BasicLogger) Errorf(format string, args ...interface{})
- func (log *BasicLogger) Fatal(args ...interface{})
- func (log *BasicLogger) Fatalf(format string, args ...interface{})
- func (log *BasicLogger) Info(args ...interface{})
- func (log *BasicLogger) InfoFunc(fn func() (string, []interface{}))
- func (log *BasicLogger) Infof(format string, args ...interface{})
- func (log *BasicLogger) Progressf(format string, args ...interface{})
- func (log *BasicLogger) Trace(args ...interface{})
- func (log *BasicLogger) TraceFunc(fn func() (string, []interface{}))
- func (log *BasicLogger) Tracef(format string, args ...interface{})
- func (log *BasicLogger) Warn(args ...interface{})
- func (log *BasicLogger) WarnFunc(fn func() (string, []interface{}))
- func (log *BasicLogger) Warnf(format string, args ...interface{})
- type LoggerImpl
- type PluginLogLevel
- type PluginLogger
- type ProgressFormatter
Constants ¶
This section is empty.
Variables ¶
var ( TraceLevel = PluginLogLevel{ // contains filtered or unexported fields } DebugLevel = PluginLogLevel{ // contains filtered or unexported fields } InfoLevel = PluginLogLevel{ // contains filtered or unexported fields } WarningLevel = PluginLogLevel{ // contains filtered or unexported fields } ErrorLevel = PluginLogLevel{ // contains filtered or unexported fields } ProgressLevel = PluginLogLevel{ // contains filtered or unexported fields } NoneLevel = PluginLogLevel{ // contains filtered or unexported fields } )
Valid Level values.
Functions ¶
func Debug ¶
func Debug(args ...interface{})
Debug calls Debug with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func DebugFunc ¶ added in v0.21.0
func DebugFunc(fn func() (string, []interface{}))
DebugFunc calls DebugFunc with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf calls Debugf with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Error ¶
func Error(args ...interface{})
Error calls Error with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func ErrorFunc ¶ added in v0.21.0
func ErrorFunc(fn func() (string, []interface{}))
ErrorFunc calls ErrorFunc with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf calls Errorf with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Fatal ¶
func Fatal(args ...interface{})
Fatal calls Fatal with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf calls Fatalf with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Info ¶
func Info(args ...interface{})
Info calls Info with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func InfoFunc ¶ added in v0.21.0
func InfoFunc(fn func() (string, []interface{}))
InfoFunc calls InfoFunc with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Infof ¶
func Infof(format string, args ...interface{})
Infof calls Infof with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Progressf ¶
func Progressf(format string, args ...interface{})
Progressf calls Progressf with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Trace ¶
func Trace(args ...interface{})
Trace calls Trace with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func TraceFunc ¶ added in v0.21.0
func TraceFunc(fn func() (string, []interface{}))
TraceFunc calls TraceFunc with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Tracef ¶ added in v0.3.0
func Tracef(format string, args ...interface{})
Tracef calls Tracef with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
func Warn ¶
func Warn(args ...interface{})
Warn calls Warn with the Logger registered using RegisterLogger. If no logger has been registered, then this function is a no-op.
Types ¶
type BasicLogger ¶ added in v0.17.0
type BasicLogger struct{}
BasicLogger logs all messages to stdout
func (*BasicLogger) Debug ¶ added in v0.17.0
func (log *BasicLogger) Debug(args ...interface{})
func (*BasicLogger) DebugFunc ¶ added in v0.21.0
func (log *BasicLogger) DebugFunc(fn func() (string, []interface{}))
func (*BasicLogger) Debugf ¶ added in v0.17.0
func (log *BasicLogger) Debugf(format string, args ...interface{})
func (*BasicLogger) Error ¶ added in v0.17.0
func (log *BasicLogger) Error(args ...interface{})
func (*BasicLogger) ErrorFunc ¶ added in v0.21.0
func (log *BasicLogger) ErrorFunc(fn func() (string, []interface{}))
func (*BasicLogger) Errorf ¶ added in v0.17.0
func (log *BasicLogger) Errorf(format string, args ...interface{})
func (*BasicLogger) Fatal ¶ added in v0.17.0
func (log *BasicLogger) Fatal(args ...interface{})
func (*BasicLogger) Fatalf ¶ added in v0.17.0
func (log *BasicLogger) Fatalf(format string, args ...interface{})
func (*BasicLogger) Info ¶ added in v0.17.0
func (log *BasicLogger) Info(args ...interface{})
func (*BasicLogger) InfoFunc ¶ added in v0.21.0
func (log *BasicLogger) InfoFunc(fn func() (string, []interface{}))
func (*BasicLogger) Infof ¶ added in v0.17.0
func (log *BasicLogger) Infof(format string, args ...interface{})
func (*BasicLogger) Progressf ¶ added in v0.17.0
func (log *BasicLogger) Progressf(format string, args ...interface{})
func (*BasicLogger) Trace ¶ added in v0.17.0
func (log *BasicLogger) Trace(args ...interface{})
func (*BasicLogger) TraceFunc ¶ added in v0.21.0
func (log *BasicLogger) TraceFunc(fn func() (string, []interface{}))
func (*BasicLogger) Tracef ¶ added in v0.17.0
func (log *BasicLogger) Tracef(format string, args ...interface{})
func (*BasicLogger) Warn ¶ added in v0.17.0
func (log *BasicLogger) Warn(args ...interface{})
func (*BasicLogger) WarnFunc ¶ added in v0.21.0
func (log *BasicLogger) WarnFunc(fn func() (string, []interface{}))
func (*BasicLogger) Warnf ¶ added in v0.17.0
func (log *BasicLogger) Warnf(format string, args ...interface{})
type LoggerImpl ¶ added in v0.14.0
type LoggerImpl interface { Progressf(format string, args ...interface{}) Trace(args ...interface{}) Tracef(format string, args ...interface{}) TraceFunc(fn func() (string, []interface{})) Debug(args ...interface{}) Debugf(format string, args ...interface{}) DebugFunc(fn func() (string, []interface{})) Info(args ...interface{}) Infof(format string, args ...interface{}) InfoFunc(fn func() (string, []interface{})) Warn(args ...interface{}) Warnf(format string, args ...interface{}) WarnFunc(fn func() (string, []interface{})) Error(args ...interface{}) Errorf(format string, args ...interface{}) ErrorFunc(fn func() (string, []interface{})) Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) }
LoggerImpl is the interface that groups logging methods.
Progressf logs using a specific progress format. Trace, Debug, Info, Warn and Error log to the applicable log level. Arguments are handled in the manner of fmt.Print. Tracef, Debugf, Infof, Warnf, Errorf log to the applicable log level. Arguments are handled in the manner of fmt.Printf. Fatal and Fatalf log to the applicable log level, then call os.Exit(1).
var Logger LoggerImpl
Logger is the LoggerImpl used when calling the global Logger functions. It is suggested to use the LoggerImpl interface directly, rather than calling global log functions.
type PluginLogLevel ¶ added in v0.10.0
type PluginLogLevel struct {
// contains filtered or unexported fields
}
PluginLogLevel represents a logging level for plugins to send log messages to stash.
func PluginLogLevelFromName ¶ added in v0.10.0
func PluginLogLevelFromName(name string) *PluginLogLevel
PluginLogLevelFromName returns the PluginLogLevel that matches the provided name or nil if the name does not match a valid value.
func (PluginLogLevel) Log ¶ added in v0.10.0
func (l PluginLogLevel) Log(args ...interface{})
Log prints the provided message to os.Stderr in a format that provides the correct LogLevel for stash. The message is formatted in the same way as fmt.Println.
func (PluginLogLevel) Logf ¶ added in v0.10.0
func (l PluginLogLevel) Logf(format string, args ...interface{})
Logf prints the provided message to os.Stderr in a format that provides the correct LogLevel for stash. The message is formatted in the same way as fmt.Printf.
type PluginLogger ¶ added in v0.10.0
type PluginLogger struct { // Logger is the LoggerImpl to forward log messages to. Logger LoggerImpl // Prefix is the prefix to prepend to log messages. Prefix string // DefaultLogLevel is the log level used if a log level prefix is not present in the received log message. DefaultLogLevel *PluginLogLevel // ProgressChan is a channel that receives float64s indicating the current progress of an operation. ProgressChan chan float64 }
PluginLogger interprets incoming log messages from plugins and logs to the appropriate log level.
func (*PluginLogger) ReadLogMessages ¶ added in v0.14.0
func (log *PluginLogger) ReadLogMessages(src io.ReadCloser)
ReadLogMessages reads plugin log messages from src, forwarding them to the PluginLoggers Logger. ProgressLevel messages are parsed as float64 and forwarded to ProgressChan. If ProgressChan is full, then the progress message is not forwarded. This method only returns when it reaches the end of src or encounters an error while reading src. This method closes src before returning.
type ProgressFormatter ¶
type ProgressFormatter struct{}