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
+1 -2
View File
@@ -6,7 +6,6 @@ import (
"fmt"
"strings"
"github.com/grafana/grafana/pkg/log"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
)
@@ -58,7 +57,7 @@ func (pb *PluginBase) registerPlugin(pluginDir string) error {
}
if !strings.HasPrefix(pluginDir, setting.StaticRootPath) {
log.Info("Plugins: Registering plugin %v", pb.Name)
plog.Info("Registering plugin", "name", pb.Name)
}
if len(pb.Dependencies.Plugins) == 0 {
+7 -4
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 {