expvarmon/ui_dummy.go

37 lines
691 B
Go
Raw Normal View History

2015-05-03 21:52:50 +08:00
package main
import (
"fmt"
"time"
)
// DummyUI is an simple console UI mockup, for testing purposes.
type DummyUI struct{}
// Init implements UI.
func (*DummyUI) Init(UIData) error { return nil }
// Close implements UI.
func (*DummyUI) Close() {}
// Update implements UI.
func (*DummyUI) Update(data UIData) {
if data.Services == nil {
return
}
fmt.Println(time.Now().Format("15:04:05 02/01"))
for _, service := range data.Services {
fmt.Printf("%s: ", service.Name)
if service.Err != nil {
fmt.Printf("ERROR: %s", service.Err)
continue
}
for _, name := range data.Vars {
fmt.Printf("%s: %v, ", name.Short(), service.Value(name))
}
fmt.Printf("\n")
}
}