// 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 }
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) }