Skip to content

Commit

Permalink
fix: improve json log stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveRuble committed Oct 25, 2021
1 parent 4444937 commit c895ca6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 13 additions & 4 deletions cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,27 @@ var logParseJson = addCommand(logCmd, &cobra.Command{
Short: "Reformats JSON logs into something easier to read",
RunE: func(cmd *cobra.Command, args []string) error {

var decoder *json.Decoder
var scanner *bufio.Scanner

if len(args) > 0 {
content := strings.Join(args, " ")
b := bytes.NewBufferString(content)
decoder = json.NewDecoder(b)
scanner = bufio.NewScanner(b)
} else {
decoder = json.NewDecoder(os.Stdin)
scanner = bufio.NewScanner(os.Stdin)
}

var err error
var data map[string]interface{}
for ; err == nil; err = decoder.Decode(&data) {
for scanner.Scan() {

text := scanner.Text()
err = json.Unmarshal([]byte(text), &data)

if err != nil{
fmt.Printf("%s %s",color.BlueString("NOT JSON: "), text)
continue
}

if len(data) == 0 {
continue
Expand Down
4 changes: 1 addition & 3 deletions cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ var releaseAddCmd = addCommand(releaseCmd, &cobra.Command{

branchDescription := viper.GetString(ArgReleaseAddBranch)
if branchDescription == "" {
if r.Slot == bosun.SlotUnstable {
branchDescription = "the develop branch"
}
branchDescription = "the develop branch"
} else {
branchDescription = "the branch " + branchDescription
}
Expand Down

0 comments on commit c895ca6

Please sign in to comment.