Ejemplo n.º 1
0
func main() {
	logger := newSignalableLogger(boshlog.NewLogger(boshlog.LevelDebug))

	defer logger.HandlePanic("Main")

	logger.Debug(mainLogTag, "Starting agent")

	fs := boshsys.NewOsFileSystem(logger)
	app := boshapp.New(logger, fs)

	err := app.Setup(os.Args)
	if err != nil {
		logger.Error(mainLogTag, "App setup %s", err.Error())
		os.Exit(1)
	}

	err = app.Run()
	if err != nil {
		logger.Error(mainLogTag, "App run %s", err.Error())
		os.Exit(1)
	}
}
Ejemplo n.º 2
0
		_, err := Levelify("unknown")
		Expect(err).To(HaveOccurred())
		Expect(err.Error()).To(Equal("Unknown LogLevel string 'unknown', expected one of [DEBUG, INFO, WARN, ERROR, NONE]"))

		_, err = Levelify("")
		Expect(err).To(HaveOccurred())
		Expect(err.Error()).To(Equal("Unknown LogLevel string '', expected one of [DEBUG, INFO, WARN, ERROR, NONE]"))
	})
})

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

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

	Describe("DebugWithDetails", func() {
		It("logs the message to Logger.out at the debug level with specially formatted arguments", func() {
			stdout, stderr := captureOutputs(func() {
				logger := NewLogger(LevelDebug)
				logger.DebugWithDetails("TAG", "some info to log", "awesome")
			})