当前位置: 首页>>代码示例>>Golang>>正文


Golang TestLogger.Buffer方法代码示例

本文整理汇总了Golang中github.com/pivotal-golang/lager/lagertest.TestLogger.Buffer方法的典型用法代码示例。如果您正苦于以下问题:Golang TestLogger.Buffer方法的具体用法?Golang TestLogger.Buffer怎么用?Golang TestLogger.Buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/pivotal-golang/lager/lagertest.TestLogger的用法示例。


在下文中一共展示了TestLogger.Buffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

						events := []EventHolder{otherEvent, event}

						eventSource.NextStub = func() (models.Event, error) {
							var e EventHolder
							time.Sleep(10 * time.Millisecond)
							if len(events) == 0 {
								return nil, nil
							}
							e, events = events[0], events[1:]
							return e.event, nil
						}
					})

					It("does not call AppCrashed", func() {
						Eventually(ccClient.AppCrashedCallCount).Should(Equal(1))
						buffer := logger.Buffer()
						Expect(buffer).To(Say("process-guid"))
						Expect(buffer).NotTo(Say("other-process-guid"))
					})
				})
			})

			Context("and after < before", func() {
				BeforeEach(func() {
					before.Instance.CrashCount = 1
				})

				It("does not call AppCrashed", func() {
					Consistently(ccClient.AppCrashedCallCount).Should(Equal(0))
				})
			})
开发者ID:emc-xchallenge,项目名称:tps,代码行数:31,代码来源:watcher_test.go

示例2:

		dummyRequest.Header.Add("Authorization", fakePassword)

		fakeResponseWriter = &apifakes.FakeResponseWriter{}
		fakeHandler = &fakes.FakeHandler{}

		logger = lagertest.NewTestLogger("backup-download-test")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.INFO))
	})

	It("should log requests that are prefixed with routePrefix", func() {
		loggerMiddleware := middleware.NewLogger(logger, routePrefix)
		loggerHandler := loggerMiddleware.Wrap(fakeHandler)

		loggerHandler.ServeHTTP(fakeResponseWriter, dummyRequest)

		logContents := logger.Buffer().Contents()
		Expect(logContents).To(ContainSubstring("request"))
		Expect(logContents).To(ContainSubstring("response"))
	})

	It("should not log credentials", func() {
		loggerMiddleware := middleware.NewLogger(logger, routePrefix)
		loggerHandler := loggerMiddleware.Wrap(fakeHandler)

		loggerHandler.ServeHTTP(fakeResponseWriter, dummyRequest)

		logContents := logger.Buffer().Contents()
		Expect(logContents).ToNot(ContainSubstring(fakePassword))
	})

	It("should call next handler", func() {
开发者ID:cautio,项目名称:switchboard,代码行数:31,代码来源:logger_test.go

示例3:

			tcpRouteMapping := db.TcpRouteMapping{
				TcpRoute: db.TcpRoute{
					RouterGroupGuid: DefaultRouterGroupGuid,
					ExternalPort:    5222,
				},
				HostPort: 61000,
				HostIP:   "some-ip-1",
			}
			err := routingApiClient.UpsertTcpRouteMappings([]db.TcpRouteMapping{tcpRouteMapping})
			Expect(err).ToNot(HaveOccurred())

			tcpRouteMappings, err := routingApiClient.TcpRouteMappings()
			Expect(err).NotTo(HaveOccurred())
			Expect(tcpRouteMappings).To(ContainElement(tcpRouteMapping))

			allOutput := logger.Buffer()
			runner := testrunner.New(routerConfigurerPath, routerConfigurerArgs)
			session, err = gexec.Start(runner.Command, allOutput, allOutput)
			Expect(err).ToNot(HaveOccurred())
		})

		AfterEach(func() {
			logger.Info("shutting-down")
			session.Signal(os.Interrupt)
			Eventually(session.Exited, 5*time.Second).Should(BeClosed())
			server.Signal(os.Interrupt)
			Eventually(server.Wait(), 5*time.Second).Should(Receive())
			oauthServer.Close()
		})

		It("syncs with routing api", func() {
开发者ID:jmptrader,项目名称:cf-tcp-router,代码行数:31,代码来源:main_test.go


注:本文中的github.com/pivotal-golang/lager/lagertest.TestLogger.Buffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。