Adding ability to print out responses as JSON.
This commit is contained in:
parent
dcb27f64c2
commit
bc28198c2d
8 changed files with 210 additions and 130 deletions
35
cmd/util.go
Normal file
35
cmd/util.go
Normal 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()
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue