Commit 15aeb4ae by bergquist

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

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