Ejemplo n.º 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
}
Ejemplo n.º 2
0
func (s *MessageTestSuite) TestGetSetStart() {
	msg := gol.LogMessage{
		"key": "value",
	}

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

	start := time.Now()
	msg.SetStart(&start)

	v, err = msg.Start()
	assert.Equal(s.T(), &start, v)
	assert.Nil(s.T(), err)
}