parent
9e5e60abc4
commit
9e0fd75fb3
|
@ -81,6 +81,10 @@ func (l *Logger) Fatalf(msg string, args ...interface{}) {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Logger) Error(args ...interface{}) {
|
||||||
|
defaultLogBroker.Records <- Record{ERROR, l.Component, fmt.Sprint(args...)}
|
||||||
|
}
|
||||||
|
|
||||||
func (l *Logger) Errorf(msg string, args ...interface{}) {
|
func (l *Logger) Errorf(msg string, args ...interface{}) {
|
||||||
defaultLogBroker.Records <- Record{ERROR, l.Component, fmt.Sprintf(msg, args...)}
|
defaultLogBroker.Records <- Record{ERROR, l.Component, fmt.Sprintf(msg, args...)}
|
||||||
}
|
}
|
||||||
|
@ -150,6 +154,7 @@ For:
|
||||||
startTime := steps[step]
|
startTime := steps[step]
|
||||||
delete(steps, step)
|
delete(steps, step)
|
||||||
duration := time.Since(startTime)
|
duration := time.Since(startTime)
|
||||||
|
l.lastProgress = ""
|
||||||
l.printRecord(Record{INFO, step.Component, step.Name + " took: " + duration.String()})
|
l.printRecord(Record{INFO, step.Component, step.Name + " took: " + duration.String()})
|
||||||
case <-l.quit:
|
case <-l.quit:
|
||||||
break For
|
break For
|
||||||
|
@ -177,11 +182,23 @@ func (l *LogBroker) printComponent(component string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *LogBroker) printLevel(level Level) {
|
||||||
|
switch level {
|
||||||
|
case INFO:
|
||||||
|
fmt.Print("[INFO] ")
|
||||||
|
case WARNING:
|
||||||
|
fmt.Print("[WARN] ")
|
||||||
|
case ERROR:
|
||||||
|
fmt.Print("[ERR] ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (l *LogBroker) printRecord(record Record) {
|
func (l *LogBroker) printRecord(record Record) {
|
||||||
if !l.newline {
|
if !l.newline {
|
||||||
fmt.Print(CLEARLINE)
|
fmt.Print(CLEARLINE)
|
||||||
}
|
}
|
||||||
l.printPrefix()
|
l.printPrefix()
|
||||||
|
l.printLevel(record.Level)
|
||||||
l.printComponent(record.Component)
|
l.printComponent(record.Component)
|
||||||
fmt.Println(record.Message)
|
fmt.Println(record.Message)
|
||||||
l.newline = true
|
l.newline = true
|
||||||
|
|
Loading…
Reference in New Issue