ccollins476ad 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_r233144219
 
 

 ##########
 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:
   Thanks, Marko.  I have changed the `fmt.Sprintf("%v")` calls to 
`hex.EncodeToString()`.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to