Commit 15aeb4ae by bergquist

tech(cli): rename log to logger to separate from server logger

parent 4c4189d6
......@@ -5,7 +5,7 @@ import (
"github.com/codegangsta/cli"
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
)
func runCommand(command func(commandLine CommandLine) error) func(context *cli.Context) {
......@@ -13,13 +13,13 @@ func runCommand(command func(commandLine CommandLine) error) func(context *cli.C
cmd := &contextCommandLine{context}
if err := command(cmd); err != nil {
log.Errorf("\n%s: ", color.RedString("Error"))
log.Errorf("%s\n\n", err)
logger.Errorf("\n%s: ", color.RedString("Error"))
logger.Errorf("%s\n\n", err)
cmd.ShowHelp()
os.Exit(1)
} else {
log.Info("\nRestart grafana after installing plugins . <service grafana-server restart>\n\n")
logger.Info("\nRestart grafana after installing plugins . <service grafana-server restart>\n\n")
}
}
}
......
......@@ -14,9 +14,10 @@ import (
"strings"
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
"github.com/lunny/log"
)
func validateInput(c CommandLine, pluginFolder string) error {
......@@ -78,10 +79,10 @@ func InstallPlugin(pluginName, version string, c CommandLine) error {
pluginName,
version)
log.Infof("installing %v @ %v\n", plugin.Id, version)
log.Infof("from url: %v\n", downloadURL)
log.Infof("into: %v\n", pluginFolder)
log.Info("\n")
logger.Infof("installing %v @ %v\n", plugin.Id, version)
logger.Infof("from url: %v\n", downloadURL)
logger.Infof("into: %v\n", pluginFolder)
logger.Info("\n")
err = downloadFile(plugin.Id, pluginFolder, downloadURL)
if err != nil {
......
package commands
import (
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
)
......@@ -18,7 +18,7 @@ func listremoteCommand(c CommandLine) error {
pluginVersion = i.Versions[0].Version
}
log.Infof("id: %v version: %s\n", i.Id, pluginVersion)
logger.Infof("id: %v version: %s\n", i.Id, pluginVersion)
}
return nil
......
......@@ -5,7 +5,7 @@ import (
"fmt"
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
)
......@@ -17,7 +17,7 @@ var validateLsCommand = func(pluginDir string) error {
return errors.New("missing path flag")
}
log.Debug("plugindir: " + pluginDir + "\n")
logger.Debug("plugindir: " + pluginDir + "\n")
pluginDirInfo, err := s.IoHelper.Stat(pluginDir)
if err != nil {
......@@ -40,11 +40,11 @@ func lsCommand(c CommandLine) error {
plugins := ls_getPlugins(pluginDir)
if len(plugins) > 0 {
log.Info("installed plugins:\n")
logger.Info("installed plugins:\n")
}
for _, plugin := range plugins {
log.Infof("%s %s %s \n", plugin.Id, color.YellowString("@"), plugin.Info.Version)
logger.Infof("%s %s %s \n", plugin.Id, color.YellowString("@"), plugin.Info.Version)
}
return nil
......
package commands
import (
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
"github.com/hashicorp/go-version"
......@@ -51,7 +51,7 @@ func upgradeAllCommand(c CommandLine) error {
}
for _, p := range pluginsToUpgrade {
log.Infof("Updating %v \n", p.Id)
logger.Infof("Updating %v \n", p.Id)
s.RemoveInstalledPlugin(pluginsDir, p.Id)
InstallPlugin(p.Id, "", c)
......
......@@ -2,7 +2,7 @@ package commands
import (
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
)
......@@ -27,6 +27,6 @@ func upgradeCommand(c CommandLine) error {
return InstallPlugin(localPlugin.Id, "", c)
}
log.Infof("%s %s is up to date \n", color.GreenString("✔"), localPlugin.Id)
logger.Infof("%s %s is up to date \n", color.GreenString("✔"), localPlugin.Id)
return nil
}
......@@ -7,7 +7,8 @@ import (
"github.com/codegangsta/cli"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
"github.com/lunny/log"
)
var version = "master"
......@@ -42,7 +43,7 @@ func isDevenvironment(pwd string) bool {
}
func main() {
SetupLogging()
setupLogging()
app := cli.NewApp()
app.Name = "Grafana cli"
......@@ -73,14 +74,14 @@ func main() {
app.CommandNotFound = cmdNotFound
if err := app.Run(os.Args); err != nil {
log.Errorf("%v", err)
logger.Errorf("%v", err)
}
}
func SetupLogging() {
func setupLogging() {
for _, f := range os.Args {
if f == "-D" || f == "--debug" || f == "-debug" {
log.SetDebug(true)
logger.SetDebug(true)
}
}
}
......
......@@ -7,7 +7,7 @@ import (
"path"
"github.com/franela/goreq"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
)
......@@ -64,7 +64,7 @@ func GetLocalPlugins(pluginDir string) []m.InstalledPlugin {
}
func RemoveInstalledPlugin(pluginPath, id string) error {
log.Infof("Removing plugin: %v\n", id)
logger.Infof("Removing plugin: %v\n", id)
return IoHelper.RemoveAll(path.Join(pluginPath, id))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment