Add timeout to kubectl get node
[iec.git] / src / foundation / api / revel / logger.go
1 package revel
2
3 import (
4         "github.com/revel/revel/logger"
5 )
6
7 //Logger
8 var (
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")
19
20         // This is the handler for the AppLog, it is stored so that if the AppLog is changed it can be assigned to the
21         // new AppLog
22         appLogHandler *logger.CompositeMultiHandler
23
24         // This oldLog is the revel logger, historical for revel, The application should use the AppLog or the Controller.oldLog
25         // DEPRECATED
26         oldLog = AppLog.New("section", "deprecated")
27         // System logger
28         SysLog = AppLog.New("section", "system")
29 )
30
31 // Initialize the loggers first
32 func init() {
33
34         //RootLog.SetHandler(
35         //      logger.LevelHandler(logger.LogLevel(log15.LvlDebug),
36         //              logger.StreamHandler(os.Stdout, logger.TerminalFormatHandler(false, true))))
37         initLoggers()
38         OnAppStart(initLoggers, -5)
39
40 }
41 func initLoggers() {
42         appHandle := logger.InitializeFromConfig(BasePath, Config)
43
44         // Set all the log handlers
45         setAppLog(AppLog, appHandle)
46 }
47
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) {
51         if appLog != nil {
52                 AppLog = appLog
53         }
54         if appHandler != nil {
55                 appLogHandler = appHandler
56                 // Set the app log and the handler for all forked loggers
57                 RootLog.SetHandler(appLogHandler)
58
59                 // Set the system log handler - this sets golang writer stream to the
60                 // sysLog router
61                 logger.SetDefaultLog(SysLog)
62                 SysLog.SetStackDepth(5)
63                 SysLog.SetHandler(appLogHandler)
64         }
65 }