Esempio 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)
	}
}
Esempio n. 2
0
			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")
			})

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

	Describe("ErrorWithDetails", func() {
		It("logs the message to Logger.err at the error level with specially formatted arguments", func() {
			stdout, stderr := captureOutputs(func() {
				logger := NewLogger(LevelError)
				logger.ErrorWithDetails("TAG", "some error to log", "awesome")
			})