Adding ability to print out responses as JSON.

This commit is contained in:
Renan DelValle 2018-11-09 15:58:26 -08:00
parent dcb27f64c2
commit bc28198c2d
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
8 changed files with 210 additions and 130 deletions

35
cmd/util.go Normal file
View file

@ -0,0 +1,35 @@
package cmd
import (
"bytes"
"encoding/json"
log "github.com/sirupsen/logrus"
)
func toJSON(v interface{}) string {
output, err := json.Marshal(v)
if err != nil {
log.Fatalln("Unable to serialize statuses")
}
return string(output)
}
func getLoggingLevels() string {
var buffer bytes.Buffer
for _, level := range log.AllLevels {
buffer.WriteString(level.String())
buffer.WriteString(" ")
}
buffer.Truncate(buffer.Len()-1)
return buffer.String()
}