當前位置: 首頁>>代碼示例>>Golang>>正文


Golang logger.NewLogger函數代碼示例

本文整理匯總了Golang中bosh/logger.NewLogger函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewLogger函數的具體用法?Golang NewLogger怎麽用?Golang NewLogger使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewLogger函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: init

func init() {
	Describe("Testing with Ginkgo", func() {
		It("running a successful task", func() {
			testRunningTask(GinkgoT(), TaskStateDone, 123, nil)
		})
		It("running a failing task", func() {

			testRunningTask(GinkgoT(), TaskStateFailed, nil, errors.New("Oops"))
		})
		It("start task generates task id", func() {

			var taskFunc = func() (value interface{}, err error) {
				return
			}

			service := NewAsyncTaskService(boshlog.NewLogger(boshlog.LEVEL_NONE))

			for expectedTaskId := 1; expectedTaskId < 20; expectedTaskId++ {
				task := service.StartTask(taskFunc)
				assert.Equal(GinkgoT(), fmt.Sprintf("%d", expectedTaskId), task.Id)
			}
		})
		It("processing many tasks simultaneously", func() {

			taskFunc := func() (value interface{}, err error) {
				time.Sleep(10 * time.Millisecond)
				return
			}

			service := NewAsyncTaskService(boshlog.NewLogger(boshlog.LEVEL_NONE))
			ids := []string{}

			for id := 1; id < 200; id++ {
				ids = append(ids, fmt.Sprintf("%d", id))
				go service.StartTask(taskFunc)
			}

			for {
				allDone := true

				for _, id := range ids {
					task, _ := service.FindTask(id)
					if task.State != TaskStateDone {
						allDone = false
						break
					}
				}

				if allDone {
					break
				}

				time.Sleep(200 * time.Millisecond)
			}
		})
	})
}
開發者ID:nkuacac,項目名稱:bosh,代碼行數:57,代碼來源:async_task_service_test.go

示例2: getActionDispatcherDependencies

func getActionDispatcherDependencies() (logger boshlog.Logger, taskService *faketask.FakeService, actionFactory *fakeaction.FakeFactory, actionRunner *fakeaction.FakeRunner) {
	logger = boshlog.NewLogger(boshlog.LEVEL_NONE)
	taskService = &faketask.FakeService{}
	actionFactory = &fakeaction.FakeFactory{}
	actionRunner = &fakeaction.FakeRunner{}
	return
}
開發者ID:UhuruSoftware,項目名稱:bosh_old,代碼行數:7,代碼來源:action_dispatcher_test.go

示例3: getNewProvider

func getNewProvider() (provider provider) {
	dirProvider := boshsys.NewDirectoriesProvider("/var/vcap")
	fs := fakefs.NewFakeFileSystem()

	provider = NewProvider(boshlog.NewLogger(boshlog.LEVEL_NONE), fs, dirProvider)
	return
}
開發者ID:kangaroo,項目名稱:bosh,代碼行數:7,代碼來源:provider_test.go

示例4: buildAlertBuilder

func buildAlertBuilder() (settingsService *fakesettings.FakeSettingsService, builder Builder) {
	logger := boshlog.NewLogger(boshlog.LEVEL_NONE)
	settingsService = &fakesettings.FakeSettingsService{}

	builder = NewBuilder(settingsService, logger)
	return
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:7,代碼來源:concrete_builder_test.go

示例5: TestGetReturnsAnAwsInfrastructure

func TestGetReturnsAnAwsInfrastructure(t *testing.T) {
	provider := NewProvider(boshlog.NewLogger(boshlog.LEVEL_NONE))
	inf, err := provider.Get("aws")

	assert.NoError(t, err)
	assert.IsType(t, awsInfrastructure{}, inf)
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:7,代碼來源:provider_test.go

示例6: TestProcessingManyTasksSimultaneously

func TestProcessingManyTasksSimultaneously(t *testing.T) {
	taskFunc := func() (value interface{}, err error) {
		time.Sleep(10 * time.Millisecond)
		return
	}

	service := NewAsyncTaskService(boshlog.NewLogger(boshlog.LEVEL_NONE))
	ids := []string{}

	for id := 1; id < 200; id++ {
		ids = append(ids, fmt.Sprintf("%d", id))
		go service.StartTask(taskFunc)
	}

	for {
		allDone := true

		for _, id := range ids {
			task, _ := service.FindTask(id)
			if task.State != TaskStateDone {
				allDone = false
				break
			}
		}

		if allDone {
			break
		}

		time.Sleep(200 * time.Millisecond)
	}
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:32,代碼來源:async_task_service_test.go

示例7: testRunningTask

func testRunningTask(t *testing.T, expectedState TaskState, withValue interface{}, withErr error) {
	service := NewAsyncTaskService(boshlog.NewLogger(boshlog.LEVEL_NONE))

	taskIsFinished := false

	task := service.StartTask(func() (value interface{}, err error) {
		for !taskIsFinished {
		}
		value = withValue
		err = withErr
		return
	})

	assert.Equal(t, "1", task.Id)
	assert.Equal(t, "running", task.State)

	taskIsFinished = true

	updatedTask, _ := service.FindTask(task.Id)

	for updatedTask.State != expectedState {
		time.Sleep(time.Nanosecond)
		updatedTask, _ = service.FindTask(task.Id)
	}
	assert.Equal(t, expectedState, updatedTask.State)
	assert.Equal(t, withValue, updatedTask.Value)

	if withErr != nil {
		assert.Equal(t, withErr.Error(), updatedTask.Error)
	} else {
		assert.Equal(t, "", updatedTask.Error)
	}
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:33,代碼來源:async_task_service_test.go

示例8: TestHandlerProviderGetReturnsAnErrorIfNotSupported

func TestHandlerProviderGetReturnsAnErrorIfNotSupported(t *testing.T) {
	settings := &fakesettings.FakeSettingsService{MbusUrl: "foo://0.0.0.0"}
	logger := boshlog.NewLogger(boshlog.LEVEL_NONE)
	provider := NewHandlerProvider(settings, logger)
	_, err := provider.Get()

	assert.Error(t, err)
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:8,代碼來源:handler_provider_test.go

示例9: buildMonit

func buildMonit() (fs *fakesys.FakeFileSystem, runner *fakesys.FakeCmdRunner, client *fakemonit.FakeMonitClient, monit monit) {
	fs = &fakesys.FakeFileSystem{}
	runner = &fakesys.FakeCmdRunner{}
	client = fakemonit.NewFakeMonitClient()
	logger := boshlog.NewLogger(boshlog.LEVEL_NONE)
	monit = NewMonit(fs, runner, client, logger)
	return
}
開發者ID:viglesiasce,項目名稱:bosh,代碼行數:8,代碼來源:monit_test.go

示例10: buildProvider

func buildProvider(mbusUrl string) (provider mbusHandlerProvider, platform *fakeplatform.FakePlatform, dirProvider boshdir.DirectoriesProvider) {
	settings := &fakesettings.FakeSettingsService{MbusUrl: mbusUrl}
	logger := boshlog.NewLogger(boshlog.LEVEL_NONE)
	provider = NewHandlerProvider(settings, logger)

	platform = fakeplatform.NewFakePlatform()
	dirProvider = boshdir.NewDirectoriesProvider("/var/vcap")
	return
}
開發者ID:UhuruSoftware,項目名稱:bosh_old,代碼行數:9,代碼來源:handler_provider_test.go

示例11: buildProvider

func buildProvider(mbusUrl string) (deps providerDeps, provider MbusHandlerProvider) {
	deps.settings = &fakesettings.FakeSettingsService{MbusUrl: mbusUrl}
	deps.logger = boshlog.NewLogger(boshlog.LEVEL_NONE)
	provider = NewHandlerProvider(deps.settings, deps.logger)

	deps.platform = fakeplatform.NewFakePlatform()
	deps.dirProvider = boshdir.NewDirectoriesProvider("/var/vcap")
	return
}
開發者ID:velankanisys,項目名稱:bosh,代碼行數:9,代碼來源:handler_provider_test.go

示例12: TestHandlerProviderGetReturnsNatsHandler

func TestHandlerProviderGetReturnsNatsHandler(t *testing.T) {
	settings := &fakesettings.FakeSettingsService{MbusUrl: "nats://0.0.0.0"}

	logger := boshlog.NewLogger(boshlog.LEVEL_NONE)
	provider := NewHandlerProvider(settings, logger)
	handler, err := provider.Get()

	assert.NoError(t, err)
	assert.IsType(t, natsHandler{}, handler)
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:10,代碼來源:handler_provider_test.go

示例13: TestStartTaskGeneratesTaskId

func TestStartTaskGeneratesTaskId(t *testing.T) {
	var taskFunc = func() (value interface{}, err error) {
		return
	}

	service := NewAsyncTaskService(boshlog.NewLogger(boshlog.LEVEL_NONE))

	for expectedTaskId := 1; expectedTaskId < 20; expectedTaskId++ {
		task := service.StartTask(taskFunc)
		assert.Equal(t, fmt.Sprintf("%d", expectedTaskId), task.Id)
	}
}
開發者ID:ian-plosker,項目名稱:bosh,代碼行數:12,代碼來源:async_task_service_test.go

示例14: init

func init() {
	Describe("Testing with Ginkgo", func() {
		It("services in group returns slice of service", func() {

			expectedServices := []Service{
				{
					Monitored: true,
					Status:    "running",
				},
				{
					Monitored: false,
					Status:    "unknown",
				},
				{
					Monitored: true,
					Status:    "starting",
				},
				{
					Monitored: true,
					Status:    "failing",
				},
			}
			monitStatusFilePath, _ := filepath.Abs("../../../../fixtures/monit_status_with_multiple_services.xml")
			Expect(monitStatusFilePath).ToNot(BeNil())

			file, err := os.Open(monitStatusFilePath)
			Expect(err).ToNot(HaveOccurred())
			defer file.Close()

			handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
				io.Copy(w, file)
				Expect(r.Method).To(Equal("GET"))
				Expect(r.URL.Path).To(Equal("/_status2"))
				Expect(r.URL.Query().Get("format")).To(Equal("xml"))
			})
			ts := httptest.NewServer(handler)
			defer ts.Close()

			logger := boshlog.NewLogger(boshlog.LEVEL_NONE)
			client := NewHttpClient(ts.Listener.Addr().String(), "fake-user", "fake-pass", http.DefaultClient, 1*time.Millisecond, logger)

			status, err := client.Status()
			Expect(err).ToNot(HaveOccurred())

			services := status.ServicesInGroup("vcap")
			Expect(len(expectedServices)).To(Equal(len(services)))

			for i, expectedService := range expectedServices {
				Expect(expectedService).To(Equal(services[i]))
			}
		})
	})
}
開發者ID:velankanisys,項目名稱:bosh,代碼行數:53,代碼來源:status_test.go

示例15: buildMonitJobSupervisor

func buildMonitJobSupervisor() (deps monitJobSupDeps, monit monitJobSupervisor) {
	deps = monitJobSupDeps{
		fs:          &fakesys.FakeFileSystem{},
		runner:      &fakesys.FakeCmdRunner{},
		client:      fakemonit.NewFakeMonitClient(),
		logger:      boshlog.NewLogger(boshlog.LEVEL_NONE),
		dirProvider: boshdir.NewDirectoriesProvider("/var/vcap"),
	}

	monit = NewMonitJobSupervisor(deps.fs, deps.runner, deps.client, deps.logger, deps.dirProvider)
	return
}
開發者ID:UhuruSoftware,項目名稱:bosh_old,代碼行數:12,代碼來源:monit_job_supervisor_test.go


注:本文中的bosh/logger.NewLogger函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。