feat(logging): a lot of progress on moving to new logging lib, #4590

This commit is contained in:
Torkel Ödegaard
2016-06-06 23:06:44 +02:00
parent 25899b72d2
commit 22778e6efd
18 changed files with 314 additions and 707 deletions

View File

@ -25,6 +25,7 @@ var (
GrafanaLatestVersion string
GrafanaHasUpdate bool
plog log.Logger
)
type PluginScanner struct {
@ -33,6 +34,8 @@ type PluginScanner struct {
}
func Init() error {
plog = log.New("plugins")
DataSources = make(map[string]*DataSourcePlugin)
StaticRoutes = make([]*PluginStaticRoute, 0)
Panels = make(map[string]*PanelPlugin)
@ -44,16 +47,16 @@ func Init() error {
"app": AppPlugin{},
}
log.Info("Plugins: Scan starting")
plog.Info("Starting plugin search")
scan(path.Join(setting.StaticRootPath, "app/plugins"))
// check if plugins dir exists
if _, err := os.Stat(setting.PluginsPath); os.IsNotExist(err) {
log.Warn("Plugins: Plugin dir %v does not exist", setting.PluginsPath)
plog.Warn("Plugin dir does not exist", "dir", setting.PluginsPath)
if err = os.MkdirAll(setting.PluginsPath, os.ModePerm); err != nil {
log.Warn("Plugins: Failed to create plugin dir: %v, error: %v", setting.PluginsPath, err)
plog.Warn("Failed to create plugin dir", "dir", setting.PluginsPath, "error", err)
} else {
log.Info("Plugins: Plugin dir %v created", setting.PluginsPath)
plog.Info("Plugin dir created", "dir", setting.PluginsPath)
scan(setting.PluginsPath)
}
} else {