func TestDumpForReturnsOnlyDumpsForTheGivenAppId(t *testing.T) {
	groupedSinks := NewGroupedSinks()
	target := "789"
	otherTarget := "790"

	sink1 := sinks.NewDumpSink(target, 5, loggertesthelper.Logger(), make(chan sinks.Sink, 1), time.Second)
	sink2 := sinks.NewDumpSink(otherTarget, 5, loggertesthelper.Logger(), make(chan sinks.Sink, 1), time.Second)

	groupedSinks.Register(sink1)
	groupedSinks.Register(sink2)

	appSink := groupedSinks.DumpFor(target)
	assert.Equal(t, appSink, sink1)
}
예제 #2
0
func (sinkManager *SinkManager) ensureRecentLogsSinkFor(appId string) {
	if sinkManager.sinks.DumpFor(appId) != nil {
		return
	}

	s := sinks.NewDumpSink(appId, sinkManager.recentLogCount, sinkManager.logger, sinkManager.sinkCloseChan, time.Hour)

	if sinkManager.RegisterSink(s) {
		go s.Run()
	}
}
예제 #3
0
func (messageRouter *messageRouter) manageDumps(activeSinks *groupedsinks.GroupedSinks, appId string) {
	if activeSinks.DumpFor(appId) == nil {
		s := sinks.NewDumpSink(appId, messageRouter.dumpBufferSize, messageRouter.logger)

		ok := messageRouter.registerSink(s, activeSinks)

		if ok {
			go s.Run()
		}
	}
}
func TestDumpForReturnsOnyDumps(t *testing.T) {
	groupedSinks := NewGroupedSinks()
	target := "789"

	sink1 := sinks.NewSyslogSink(target, "url1", loggertesthelper.Logger(), DummySyslogWriter{}, make(chan<- *logmessage.Message))
	sink2 := sinks.NewSyslogSink(target, "url2", loggertesthelper.Logger(), DummySyslogWriter{}, make(chan<- *logmessage.Message))
	sink3 := sinks.NewDumpSink(target, 5, loggertesthelper.Logger(), make(chan sinks.Sink, 1), time.Second)

	groupedSinks.Register(sink1)
	groupedSinks.Register(sink2)
	groupedSinks.Register(sink3)

	appSink := groupedSinks.DumpFor(target)
	assert.Equal(t, appSink, sink3)
}
예제 #5
0
func TestDumpForReturnsOnyDumps(t *testing.T) {
	groupedSinks := NewGroupedSinks()
	target := "789"

	sink1 := sinks.NewSyslogSink(target, "url1", loggertesthelper.Logger(), syslogWriter)
	sink2 := sinks.NewSyslogSink(target, "url2", loggertesthelper.Logger(), syslogWriter)
	sink3 := sinks.NewDumpSink(target, 5, loggertesthelper.Logger())

	groupedSinks.Register(sink1)
	groupedSinks.Register(sink2)
	groupedSinks.Register(sink3)

	appSink := groupedSinks.DumpFor(target)
	assert.Equal(t, appSink, sink3)
}
func TestDrainsFor(t *testing.T) {
	groupedSinks := NewGroupedSinks()
	target := "789"
	otherTarget := "790"

	sink1 := sinks.NewDumpSink(target, 10, loggertesthelper.Logger(), make(chan sinks.Sink, 1), time.Second)
	sink2 := sinks.NewSyslogSink(target, "url", loggertesthelper.Logger(), DummySyslogWriter{}, make(chan<- *logmessage.Message))
	sink3 := sinks.NewSyslogSink(otherTarget, "url", loggertesthelper.Logger(), DummySyslogWriter{}, make(chan<- *logmessage.Message))

	groupedSinks.Register(sink1)
	groupedSinks.Register(sink2)
	groupedSinks.Register(sink3)

	appSinks := groupedSinks.DrainsFor(target)
	assert.Equal(t, len(appSinks), 1)
	assert.Equal(t, appSinks[0], sink2)
}
예제 #7
0
func TestDrainsFor(t *testing.T) {
	groupedSinks := NewGroupedSinks()
	target := "789"
	otherTarget := "790"

	sink1 := sinks.NewDumpSink(target, 10, loggertesthelper.Logger())
	sink2 := sinks.NewSyslogSink(target, "url", loggertesthelper.Logger(), syslogWriter)
	sink3 := sinks.NewSyslogSink(otherTarget, "url", loggertesthelper.Logger(), syslogWriter)

	groupedSinks.Register(sink1)
	groupedSinks.Register(sink2)
	groupedSinks.Register(sink3)

	appSinks := groupedSinks.DrainsFor(target)
	assert.Equal(t, len(appSinks), 1)
	assert.Equal(t, appSinks[0], sink2)
}