Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 68f5c73bb -> e1aa9abfe


MYNEWT-568 log - newtmgr logs show; idx before ts.

Now that the index is the "primary key," it comes earlier in the
argument list than the optional timestamp.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/e1aa9abf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/e1aa9abf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/e1aa9abf

Branch: refs/heads/develop
Commit: e1aa9abfe5f6219b5f9268a2599f37432be60ba1
Parents: 68f5c73
Author: Christopher Collins <[email protected]>
Authored: Thu Jan 26 17:44:22 2017 -0800
Committer: Christopher Collins <[email protected]>
Committed: Thu Jan 26 17:51:17 2017 -0800

----------------------------------------------------------------------
 newtmgr/cli/logs.go | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e1aa9abf/newtmgr/cli/logs.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/logs.go b/newtmgr/cli/logs.go
index d7ff96e..6c3503a 100644
--- a/newtmgr/cli/logs.go
+++ b/newtmgr/cli/logs.go
@@ -127,20 +127,24 @@ func logsShowCmd(cmd *cobra.Command, args []string) {
                nmUsage(cmd, err)
        }
 
-
-       if len(args) > 0 {
+       if len(args) >= 1 {
                req.Name = args[0]
-               if len(args) > 1 {
-            if args[1] == "last" {
-                req.Timestamp = -1
-            } else {
-                req.Timestamp, err = strconv.ParseInt(args[1], 0, 64)
-                if len(args) > 2 {
-                    req.Index, err = strconv.ParseUint(args[2], 0, 64)
-                }
-            }
+       }
+
+       if len(args) >= 2 {
+               if args[1] == "last" {
+                       req.Index = 0
+                       req.Timestamp = -1
+               } else {
+                       req.Index, err = strconv.ParseUint(args[1], 0, 64)
+                       if err != nil {
+                               nmUsage(cmd, err)
+                       }
                }
+       }
 
+       if len(args) >= 3 && req.Timestamp != -1 {
+               req.Timestamp, err = strconv.ParseInt(args[1], 0, 64)
                if err != nil {
                        nmUsage(cmd, err)
                }
@@ -166,12 +170,11 @@ func logsShowCmd(cmd *cobra.Command, args []string) {
        }
 
        for j := 0; j < len(decodedResponse.Logs); j++ {
-
                fmt.Println("Name:", decodedResponse.Logs[j].Name)
                fmt.Println("Type:", 
LogTypeToString(decodedResponse.Logs[j].Type))
 
                for i := 0; i < len(decodedResponse.Logs[j].Entries); i++ {
-                       fmt.Println(fmt.Sprintf("%+v usecs, %+v > %s: %s: %s",
+                       fmt.Println(fmt.Sprintf("%20d usecs %10d > %s: %s: %s",
                                decodedResponse.Logs[j].Entries[i].Timestamp,
                                decodedResponse.Logs[j].Entries[i].Index,
                                
LogModuleToString(decodedResponse.Logs[j].Entries[i].Module),
@@ -331,7 +334,7 @@ func logsCmd() *cobra.Command {
        }
 
        showCmd := &cobra.Command{
-               Use:   "show",
+               Use:   "show [log-name] [min-index] [min-timestamp]",
                Short: "Show logs on target",
                Run:   logsShowCmd,
        }

Reply via email to