Beispiel #1
0
			logger := NewWriterLogger(LevelDebug, outBuf, errBuf)
			logger.DebugWithDetails("TAG", "some info to log", "awesome")
			expectedContent := expectedLogFormat("TAG", "DEBUG - some info to log")
			Expect(outBuf).To(MatchRegexp(expectedContent))
			Expect(errBuf).ToNot(MatchRegexp(expectedContent))

			expectedDetails := "\n********************\nawesome\n********************"
			Expect(outBuf).To(ContainSubstring(expectedDetails))
			Expect(errBuf).ToNot(ContainSubstring(expectedDetails))
		})
	})

	Describe("Info", func() {
		It("logs the formatted message to Logger.out at the info level", func() {
			logger := NewWriterLogger(LevelInfo, outBuf, errBuf)
			logger.Info("TAG", "some %s info to log", "awesome")

			expectedContent := expectedLogFormat("TAG", "INFO - some awesome info to log")
			Expect(outBuf).To(MatchRegexp(expectedContent))
			Expect(errBuf).ToNot(MatchRegexp(expectedContent))
		})
	})

	Describe("Warn", func() {
		It("logs the formatted message to Logger.err at the warn level", func() {
			logger := NewWriterLogger(LevelWarn, outBuf, errBuf)
			logger.Warn("TAG", "some %s info to log", "awesome")

			expectedContent := expectedLogFormat("TAG", "WARN - some awesome info to log")
			Expect(outBuf).ToNot(MatchRegexp(expectedContent))
			Expect(errBuf).To(MatchRegexp(expectedContent))
Beispiel #2
0
			expectedContent := expectedLogFormat("TAG", "DEBUG - some info to log")
			Expect(stdout).To(MatchRegexp(expectedContent))
			Expect(stderr).ToNot(MatchRegexp(expectedContent))

			expectedDetails := "\n********************\nawesome\n********************"
			Expect(stdout).To(ContainSubstring(expectedDetails))
			Expect(stderr).ToNot(ContainSubstring(expectedDetails))
		})
	})

	Describe("Info", func() {
		It("logs the formatted message to Logger.out at the info level", func() {
			stdout, stderr := captureOutputs(func() {
				logger := NewLogger(LevelInfo)
				logger.Info("TAG", "some %s info to log", "awesome")
			})

			expectedContent := expectedLogFormat("TAG", "INFO - some awesome info to log")
			Expect(stdout).To(MatchRegexp(expectedContent))
			Expect(stderr).ToNot(MatchRegexp(expectedContent))
		})
	})

	Describe("Warn", func() {
		It("logs the formatted message to Logger.err at the warn level", func() {
			stdout, stderr := captureOutputs(func() {
				logger := NewLogger(LevelWarn)
				logger.Warn("TAG", "some %s info to log", "awesome")
			})