Ejemplo n.º 1
0
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)
	}
}
Ejemplo n.º 2
0
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
}