Exemple #1
0
// Filter performs a filter check on the given message.
// Returns whether or not a given message should be filtered.
func (f Threshold) Filter(msg *gol.LogMessage) bool {
	var start *time.Time
	var stop *time.Time
	var err error

	if start, err = msg.Start(); err != nil {
		return true
	}
	if stop, err = msg.Stop(); err != nil {
		return true
	}

	return stop.Sub(*start) >= f.threshold
}
Exemple #2
0
func (s *MessageTestSuite) TestGetSetStop() {
	msg := gol.LogMessage{
		"key": "value",
	}

	v, err := msg.Stop()
	assert.Equal(s.T(), &time.Time{}, v)
	assert.Equal(s.T(), fmt.Errorf("Message does not contain field stop"), err)

	stop := time.Now()
	msg.SetStop(&stop)

	v, err = msg.Stop()
	assert.Equal(s.T(), &stop, v)
	assert.Nil(s.T(), err)
}