代码拉取完成,页面将自动刷新
package log
import (
"fmt"
"io"
"os"
)
type FmtMachineLogger struct {
outWriter io.Writer
errWriter io.Writer
debug bool
history *HistoryRecorder
}
// NewFmtMachineLogger creates a MachineLogger implementation used by the drivers
func NewFmtMachineLogger() MachineLogger {
return &FmtMachineLogger{
outWriter: os.Stdout,
errWriter: os.Stderr,
debug: false,
history: NewHistoryRecorder(),
}
}
func (ml *FmtMachineLogger) SetDebug(debug bool) {
ml.debug = debug
}
func (ml *FmtMachineLogger) SetOutWriter(out io.Writer) {
ml.outWriter = out
}
func (ml *FmtMachineLogger) SetErrWriter(err io.Writer) {
ml.errWriter = err
}
func (ml *FmtMachineLogger) Debug(args ...interface{}) {
ml.history.Record(args...)
if ml.debug {
fmt.Fprintln(ml.errWriter, args...)
}
}
func (ml *FmtMachineLogger) Debugf(fmtString string, args ...interface{}) {
ml.history.Recordf(fmtString, args...)
if ml.debug {
fmt.Fprintf(ml.errWriter, fmtString+"\n", args...)
}
}
func (ml *FmtMachineLogger) Error(args ...interface{}) {
ml.history.Record(args...)
fmt.Fprintln(ml.errWriter, args...)
}
func (ml *FmtMachineLogger) Errorf(fmtString string, args ...interface{}) {
ml.history.Recordf(fmtString, args...)
fmt.Fprintf(ml.errWriter, fmtString+"\n", args...)
}
func (ml *FmtMachineLogger) Info(args ...interface{}) {
ml.history.Record(args...)
fmt.Fprintln(ml.outWriter, args...)
}
func (ml *FmtMachineLogger) Infof(fmtString string, args ...interface{}) {
ml.history.Recordf(fmtString, args...)
fmt.Fprintf(ml.outWriter, fmtString+"\n", args...)
}
func (ml *FmtMachineLogger) Warn(args ...interface{}) {
ml.history.Record(args...)
fmt.Fprintln(ml.outWriter, args...)
}
func (ml *FmtMachineLogger) Warnf(fmtString string, args ...interface{}) {
ml.history.Recordf(fmtString, args...)
fmt.Fprintf(ml.outWriter, fmtString+"\n", args...)
}
func (ml *FmtMachineLogger) History() []string {
return ml.history.records
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。