return } var _ = Describe("SignalableLogger", func() { var ( signalChannel chan os.Signal ) BeforeEach(func() { signalChannel = make(chan os.Signal, 1) }) Describe("Toggling forced debug", func() { Describe("when the log level is error", func() { It("outputs at debug level", func() { stdout, stderr := captureOutputs(func() { logger, doneChannel := bilog.NewSignalableLogger(boshlog.NewLogger(boshlog.LevelError), signalChannel) signalChannel <- syscall.SIGHUP <-doneChannel logger.Debug("TOGGLED_DEBUG", "some debug log") logger.Info("TOGGLED_INFO", "some info log") logger.Warn("TOGGLED_WARN", "some warn log") logger.Error("TOGGLED_ERROR", "some error log") }) Expect(stdout).To(ContainSubstring("TOGGLED_DEBUG")) Expect(stdout).To(ContainSubstring("TOGGLED_INFO")) Expect(stderr).To(ContainSubstring("TOGGLED_WARN")) Expect(stderr).To(ContainSubstring("TOGGLED_ERROR")) })
func newSignalableLogger(logger boshlog.Logger) boshlog.Logger { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGHUP) signalableLogger, _ := bilog.NewSignalableLogger(logger, c) return signalableLogger }