// NewLogger creates a Contextual logger from a log.Logger. func NewLogger(l *log.Logger) loggers.Contextual { var g goLog g.logger = l a := mappers.NewContextualMap(&g) a.Debug("Now using Go's stdlib log package (via loggers/mappers/stdlib).") return a }
// NewDefaultLogger returns a Contextual logger using a *testing.T with Log/Logf output. // This allows logging to be redirected to the test where it belongs. func NewTestingLogger(t *testing.T) loggers.Contextual { var g goTestLog g.logger = t a := mappers.NewContextualMap(&g) a.Debug("Now using Go's stdlib testing log (via loggers/mappers/stdlib).") return a }
// NewDefaultLogger returns a Contextual logger using a log.Logger with stderr output. func NewDefaultLogger() loggers.Contextual { var g goLog g.logger = log.New(os.Stderr, "", log.Ldate|log.Ltime) a := mappers.NewContextualMap(&g) a.Debug("Now using Go's stdlib log package (via loggers/mappers/stdlib).") return a }
// NewLogger returns a Contextual Logger for revel's internal logger. // Note that Revel's loggers must be initialized before any logging can be made. func NewLogger() loggers.Contextual { var l *Logger var a = mappers.NewContextualMap(l) a.Info("Now using Revel's logger package (via loggers/mappers/revel).") // Remove filename printing from revel logger. revel.TRACE.SetFlags(stdlog.Ldate | stdlog.Ltime) revel.INFO.SetFlags(stdlog.Ldate | stdlog.Ltime) revel.WARN.SetFlags(stdlog.Ldate | stdlog.Ltime) revel.ERROR.SetFlags(stdlog.Ldate | stdlog.Ltime) return a }