本文整理汇总了Golang中github.com/youtube/vitess/go/streamlog.StreamLogger类的典型用法代码示例。如果您正苦于以下问题:Golang StreamLogger类的具体用法?Golang StreamLogger怎么用?Golang StreamLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StreamLogger类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: buildFmter
func buildFmter(logger *streamlog.StreamLogger) func(url.Values, interface{}) string {
type formatter interface {
Format(url.Values) string
}
return func(params url.Values, val interface{}) string {
fmter, ok := val.(formatter)
if !ok {
return fmt.Sprintf("Error: unexpected value of type %T in %s!", val, logger.Name())
}
return fmter.Format(params)
}
}
示例2: newEventCatcher
func newEventCatcher(logger *streamlog.StreamLogger) *eventCatcher {
catcher := &eventCatcher{
start: time.Now(),
logger: logger,
in: logger.Subscribe("endtoend"),
out: make(chan interface{}, 20),
}
go func() {
for event := range catcher.in {
endTime := event.(interface {
EventTime() time.Time
}).EventTime()
if endTime.Before(catcher.start) {
continue
}
catcher.out <- event
}
close(catcher.out)
}()
return catcher
}