You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/11/05 15:07:45 UTC

[GitHub] mkiiskila commented on a change in pull request #110: log: Display CBOR/binary log entries as text

mkiiskila commented on a change in pull request #110: log: Display CBOR/binary log entries as text
URL: https://github.com/apache/mynewt-newtmgr/pull/110#discussion_r230783679
 
 

 ##########
 File path: newtmgr/cli/log.go
 ##########
 @@ -89,16 +106,45 @@ func logShowCmd(cmd *cobra.Command, args []string) {
 			return
 		}
 
-		fmt.Printf("%10s %22s | %11s %11s %6s %s\n",
-			"[index]", "[timestamp]", "[module]", "[level]", "[type]", "[message]")
+		fmt.Printf("%10s %22s | %16s %16s %6s %s\n",
+			"[index]", "[timestamp]", "[module]", "[level]", "[type]",
+			"[message]")
 		for _, entry := range log.Entries {
-			fmt.Printf("%10d %20dus | %11s %11s %6s %s\n",
+			modText := fmt.Sprintf("%s (%d)",
+				nmp.LogModuleToString(int(entry.Module)), entry.Module)
+			levText := fmt.Sprintf("%s (%d)",
+				nmp.LogLevelToString(int(entry.Level)), entry.Level)
+
+			msgText := ""
+			switch entry.Type {
+			case nmp.LOG_ENTRY_TYPE_STRING:
+				msgText = string(entry.Msg)
+			case nmp.LOG_ENTRY_TYPE_CBOR:
+				msgText, err = logCborMsgText(entry.Msg)
+				if err != nil {
+					fmt.Printf("Error decoding CBOR entry: %s; "+
+						"idx=%d",
+						err.Error(), entry.Index)
+					msgText = fmt.Sprintf("%v", entry.Msg)
+				}
+
+			case nmp.LOG_ENTRY_TYPE_BINARY:
+				msgText = fmt.Sprintf("%v", entry.Msg)
 
 Review comment:
   Maybe msgText = hex.EncodeToString(entry.Msg) ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services