1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-12-02 15:37:52 +01:00
gojekyll/commands/logging.go

29 lines
563 B
Go
Raw Permalink Normal View History

2017-07-19 22:06:43 +02:00
package commands
2017-07-02 15:38:00 +02:00
import (
"fmt"
2017-07-09 22:17:20 +02:00
"github.com/osteele/gojekyll/utils"
2017-07-02 15:38:00 +02:00
)
2017-07-03 19:16:25 +02:00
type bannerLogger struct{ labelWidth int }
2017-07-02 15:38:00 +02:00
2017-07-03 19:16:25 +02:00
var logger = bannerLogger{}
func (l *bannerLogger) Info(a ...interface{}) {
fmt.Println(a...)
2017-07-02 15:38:00 +02:00
}
2017-07-03 19:16:25 +02:00
func (l *bannerLogger) label(label string, msg string, a ...interface{}) {
if len(label) > l.labelWidth {
l.labelWidth = len(label)
2017-07-02 15:38:00 +02:00
}
if !quiet {
2017-07-09 22:17:20 +02:00
fmt.Printf("%s %s\n", utils.LeftPad(label, l.labelWidth), fmt.Sprintf(msg, a...))
2017-07-02 15:38:00 +02:00
}
}
2017-07-03 19:16:25 +02:00
func (l *bannerLogger) path(label string, filename string) {
2017-07-09 22:17:20 +02:00
l.label(label, utils.MustAbs(filename))
2017-07-03 19:16:25 +02:00
}