Esempio n. 1
0
func TestFormatterTagged(t *testing.T) {
	assert := assert.New(t)

	formatter := new(StandardSinkFormatter)
	formatter.SetFormat("[%time%] [%severity%] - %message% (%tags%)")
	var msg core.LogMessage = core.CreateTaggedLogMessage("DEBUG", "test", []string{"A", "B"})

	output := formatter.GetFormattedMessage(msg)
	expected := fmt.Sprintf("[%s] [%s] - %s (%s)", msg.Time().Format(time.RFC3339), "DEBUG", "test", "A,B")

	assert.EqualValues(expected, output)
}
Esempio n. 2
0
func TestFilterSeverityTagsExclude(t *testing.T) {
	assert := assert.New(t)

	filter := StandardSinkFilter{
		severityComparator: MakeStringSeverityComparator([]string{"TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL"}),
		filter: core.Filter{
			Severity: core.FilterSeverity{
				CmpOp: core.FILTER_CMP_GT,
				Level: "INFO",
			},
			Tags:        []string{"ACCESS", "ERROR"},
			TagsExclude: true,
		},
	}
	assert.False(filter.ShouldOutput(core.CreateTaggedLogMessage("TRACE", "", []string{"SOMETHING", "ACCESS"})))
	assert.False(filter.ShouldOutput(core.CreateTaggedLogMessage("DEBUG", "", []string{"SOMETHING"})))
	assert.False(filter.ShouldOutput(core.CreateTaggedLogMessage("INFO", "", []string{"ACCESS"})))
	assert.False(filter.ShouldOutput(core.CreateTaggedLogMessage("WARNING", "", []string{"ACCESS", "SOMETHING"})))
	assert.False(filter.ShouldOutput(core.CreateTaggedLogMessage("ERROR", "", []string{"SOMETHING", "ERROR"})))
	assert.True(filter.ShouldOutput(core.CreateTaggedLogMessage("FATAL", "", []string{"SOMETHING"})))
}
Esempio n. 3
0
func (this TaggedLogSource) Fatal(message string) {
	this.dispatcher.Log(core.CreateTaggedLogMessage("FATAL", message, this.tags))
}
Esempio n. 4
0
func (this TaggedLogSource) Error(message string) {
	this.dispatcher.Log(core.CreateTaggedLogMessage("ERROR", message, this.tags))
}
Esempio n. 5
0
func (this TaggedLogSource) Warning(message string) {
	this.dispatcher.Log(core.CreateTaggedLogMessage("WARNING", message, this.tags))
}
Esempio n. 6
0
func (this TaggedLogSource) Info(message string) {
	this.dispatcher.Log(core.CreateTaggedLogMessage("INFO", message, this.tags))
}
Esempio n. 7
0
func (this TaggedLogSource) Debug(message string) {
	this.dispatcher.Log(core.CreateTaggedLogMessage("DEBUG", message, this.tags))
}
Esempio n. 8
0
func (this TaggedLogSource) Trace(message string) {
	this.dispatcher.Log(core.CreateTaggedLogMessage("TRACE", message, this.tags))
}