4 "github.com/revel/revel/logger"
9 // The root log is what all other logs are branched from, meaning if you set the handler for the root
10 // it will adjust all children
11 RootLog = logger.New()
12 // This logger is the application logger, use this for your application log messages - ie jobs and startup,
13 // Use Controller.Log for Controller logging
14 // The requests are logged to this logger with the context of `section:requestlog`
15 AppLog = RootLog.New("module", "app")
16 // This is the logger revel writes to, added log messages will have a context of module:revel in them
17 // It is based off of `RootLog`
18 RevelLog = RootLog.New("module", "revel")
20 // This is the handler for the AppLog, it is stored so that if the AppLog is changed it can be assigned to the
22 appLogHandler *logger.CompositeMultiHandler
24 // This oldLog is the revel logger, historical for revel, The application should use the AppLog or the Controller.oldLog
26 oldLog = AppLog.New("section", "deprecated")
28 SysLog = AppLog.New("section", "system")
31 // Initialize the loggers first
35 // logger.LevelHandler(logger.LogLevel(log15.LvlDebug),
36 // logger.StreamHandler(os.Stdout, logger.TerminalFormatHandler(false, true))))
38 OnAppStart(initLoggers, -5)
42 appHandle := logger.InitializeFromConfig(BasePath, Config)
44 // Set all the log handlers
45 setAppLog(AppLog, appHandle)
48 // Set the application log and handler, if handler is nil it will
49 // use the same handler used to configure the application log before
50 func setAppLog(appLog logger.MultiLogger, appHandler *logger.CompositeMultiHandler) {
54 if appHandler != nil {
55 appLogHandler = appHandler
56 // Set the app log and the handler for all forked loggers
57 RootLog.SetHandler(appLogHandler)
59 // Set the system log handler - this sets golang writer stream to the
61 logger.SetDefaultLog(SysLog)
62 SysLog.SetStackDepth(5)
63 SysLog.SetHandler(appLogHandler)