2018-06-21 14:49:35 +00:00
|
|
|
package hclog
|
|
|
|
|
|
|
|
import (
|
2019-06-19 12:50:48 +00:00
|
|
|
"io"
|
2018-06-21 14:49:35 +00:00
|
|
|
"io/ioutil"
|
2019-06-19 12:50:48 +00:00
|
|
|
"log"
|
2018-06-21 14:49:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewNullLogger instantiates a Logger for which all calls
|
|
|
|
// will succeed without doing anything.
|
|
|
|
// Useful for testing purposes.
|
|
|
|
func NewNullLogger() Logger {
|
|
|
|
return &nullLogger{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type nullLogger struct{}
|
|
|
|
|
2020-01-28 23:50:41 +00:00
|
|
|
func (l *nullLogger) Log(level Level, msg string, args ...interface{}) {}
|
|
|
|
|
2018-06-21 14:49:35 +00:00
|
|
|
func (l *nullLogger) Trace(msg string, args ...interface{}) {}
|
|
|
|
|
|
|
|
func (l *nullLogger) Debug(msg string, args ...interface{}) {}
|
|
|
|
|
|
|
|
func (l *nullLogger) Info(msg string, args ...interface{}) {}
|
|
|
|
|
|
|
|
func (l *nullLogger) Warn(msg string, args ...interface{}) {}
|
|
|
|
|
|
|
|
func (l *nullLogger) Error(msg string, args ...interface{}) {}
|
|
|
|
|
|
|
|
func (l *nullLogger) IsTrace() bool { return false }
|
|
|
|
|
|
|
|
func (l *nullLogger) IsDebug() bool { return false }
|
|
|
|
|
|
|
|
func (l *nullLogger) IsInfo() bool { return false }
|
|
|
|
|
|
|
|
func (l *nullLogger) IsWarn() bool { return false }
|
|
|
|
|
|
|
|
func (l *nullLogger) IsError() bool { return false }
|
|
|
|
|
2020-01-28 23:50:41 +00:00
|
|
|
func (l *nullLogger) ImpliedArgs() []interface{} { return []interface{}{} }
|
|
|
|
|
2018-06-21 14:49:35 +00:00
|
|
|
func (l *nullLogger) With(args ...interface{}) Logger { return l }
|
|
|
|
|
2020-01-28 23:50:41 +00:00
|
|
|
func (l *nullLogger) Name() string { return "" }
|
|
|
|
|
2018-06-21 14:49:35 +00:00
|
|
|
func (l *nullLogger) Named(name string) Logger { return l }
|
|
|
|
|
|
|
|
func (l *nullLogger) ResetNamed(name string) Logger { return l }
|
|
|
|
|
2019-06-19 12:50:48 +00:00
|
|
|
func (l *nullLogger) SetLevel(level Level) {}
|
|
|
|
|
2018-06-21 14:49:35 +00:00
|
|
|
func (l *nullLogger) StandardLogger(opts *StandardLoggerOptions) *log.Logger {
|
2019-06-19 12:50:48 +00:00
|
|
|
return log.New(l.StandardWriter(opts), "", log.LstdFlags)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *nullLogger) StandardWriter(opts *StandardLoggerOptions) io.Writer {
|
|
|
|
return ioutil.Discard
|
|
|
|
}
|