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)) }) }) Describe("Error", func() { It("logs the formatted message to Logger.err at the error level", func() { logger := NewWriterLogger(LevelError, outBuf, errBuf) logger.Error("TAG", "some %s info to log", "awesome") expectedContent := expectedLogFormat("TAG", "ERROR - some awesome info to log") Expect(outBuf).ToNot(MatchRegexp(expectedContent)) Expect(errBuf).To(MatchRegexp(expectedContent))
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") }) expectedContent := expectedLogFormat("TAG", "WARN - some awesome info to log") Expect(stdout).ToNot(MatchRegexp(expectedContent)) Expect(stderr).To(MatchRegexp(expectedContent)) }) }) Describe("Error", func() { It("logs the formatted message to Logger.err at the error level", func() { stdout, stderr := captureOutputs(func() { logger := NewLogger(LevelError) logger.Error("TAG", "some %s info to log", "awesome") })