示例#1
0
func StartS3Logger(
	coordinator *RotateCoordinator,
	info *gen.InstanceInfo,
	notifier uploader.NotifierHarness,
	builder uploader.UploaderConstructor,
	errorLogger uploader.ErrorNotifierHarness,
	numWorkers int,
) (*UploadLogger, error) {

	u := uploader.StartUploaderPool(
		numWorkers,
		errorLogger,
		notifier,
		builder,
	)
	log, err := StartS3LogWriter(u, info, coordinator)
	if err != nil {
		return nil, err
	}

	return &UploadLogger{
		Logger:   log,
		Uploader: u,
	}, nil
}
示例#2
0
func TestLogger(t *testing.T) {
	var b bytes.Buffer
	log := NewConsoleLogWriter(&b)
	u := UploadLogger{
		Logger: log,
		Uploader: uploader.StartUploaderPool(
			2,
			&testErrorLogger{},
			&testNotifier{},
			&testNothingBuilder{},
		),
	}
	u.Log("%s %d %s", "Het", 54223, "Asdf")

	u.Close()
	if b.String() != "Het 54223 Asdf\n" {
		t.Logf("%s but got %s", "Het 54223 Asdf\n", b.String())
		t.Fail()
	}
}