Example #1
0
File: app.go Project: ts33kr/boot
// Build an adequate instance of the structured logger for this
// application instance. The journal builder may draw data from the
// app instance to configure the journal correctly. This method only
// instantiates a very basic journal; anything more complicated than
// that should be implementing using a boot.Provider to do it.
func (app *App) makeJournal(level logrus.Level) *logrus.Logger {
	const m = "begin writing application journal"
	var journal *logrus.Logger = &logrus.Logger{}
	formatter := new(logrus.TextFormatter)  // std
	journal.Level = level                   // use requested level
	journal.Out = os.Stdout                 // all goes to stdout
	journal.Hooks = make(logrus.LevelHooks) // empty
	journal.Formatter = formatter           // set formatter
	formatter.ForceColors = false           // act smart
	formatter.DisableColors = false         // make pretty
	formatter.DisableTimestamp = false      // is useful
	formatter.FullTimestamp = false         // numbers
	formatter.TimestampFormat = time.StampMilli
	formatter.DisableSorting = false // order!
	moment := time.Now().Format(app.TimeLayout)
	journal.WithField("time", moment).Info(m)
	return journal // is ready to use
}