Skip to content

Commit

Permalink
client.Client.Run should print it's message to debug
Browse files Browse the repository at this point in the history
Also added logger.Logger.Infoln that wraps log.Logger.Println
  • Loading branch information
Zachary Scott committed Jun 6, 2018
1 parent c38eeeb commit 3fdf2b3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c *Client) Run(query string) (map[string]interface{}, error) {
ctx := context.Background()
var resp map[string]interface{}

c.logger.Info("Querying ", c.endpoint, " with:\n\n", query, "\n\n")
c.logger.Debug("Querying %s with:\n\n%s\n\n", c.endpoint, query)
err := c.client.Run(ctx, req, &resp)
return resp, err
}
7 changes: 4 additions & 3 deletions cmd/diagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ func diagnostic(cmd *cobra.Command, args []string) {
endpoint := viper.GetString("endpoint")
token := viper.GetString("token")

Logger.Info("\n---\nCircleCI CLI Diagnostics\n---\n\n")
Logger.Infoln("\n---\nCircleCI CLI Diagnostics\n---\n")
Logger.Infof("Config found: `%v`\n", viper.ConfigFileUsed())

Logger.Infof("GraphQL API endpoint: %s\n", endpoint)

if token == "token" || token == "" {
Logger.Info("Please set a token!")
var err error
Logger.FatalOnError("Please set a token!", err)
} else {
Logger.Info("OK, got a token.")
Logger.Infoln("OK, got a token.")
}
}
3 changes: 1 addition & 2 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ func query(cmd *cobra.Command, args []string) {
b, err := json.MarshalIndent(resp, "", " ")
Logger.FatalOnError("Could not parse graphql response", err)

Logger.Info("Result: \n\n")
Logger.Info(string(b) + "\n")
Logger.Infoln(string(b))
}
10 changes: 2 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,10 @@ func createConfig() (err error) {
endpoint := viper.GetString("endpoint")
token := viper.GetString("token")

if endpoint == "endpoint" || endpoint == "" {
Logger.Info("Please enter the HTTP(S) endpoint to your CircleCI GraphQL API:")
fmt.Scanln(&endpoint)
Logger.Info("OK.\n")
}

if token == "token" || token == "" {
Logger.Info("Please enter your CircleCI API token: ")
fmt.Scanln(&token)
Logger.Info("OK.\n")
Logger.Infoln("OK.")
}

// format input
Expand All @@ -144,6 +138,6 @@ func createConfig() (err error) {
}

Logger.Info("Your configuration has been created in `%v`.\n", cfgPathDefault)
Logger.Info("It can edited manually for advanced settings.\n")
Logger.Infoln("It can edited manually for advanced settings.")
return err
}
6 changes: 6 additions & 0 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func (l *Logger) Info(args ...interface{}) {
l.info.Print(args...)
}

// Infoln prints all args to os.Stdout followed by a newline.
// This method wraps log.Logger.Println
func (l *Logger) Infoln(args ...interface{}) {
l.info.Println(args...)
}

// Infof prints a formatted message to stdout
// This method wraps log.Logger.Printf
func (l *Logger) Infof(format string, args ...interface{}) {
Expand Down

0 comments on commit 3fdf2b3

Please sign in to comment.