You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/03/10 00:17:49 UTC

[1/2] incubator-mynewt-newt git commit: Small rename (ResolveTargetNames -> ResolveTargets)

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 11f7e0c89 -> 6d5c21828


Small rename (ResolveTargetNames -> ResolveTargets)


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/d2266172
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/d2266172
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/d2266172

Branch: refs/heads/develop
Commit: d2266172dc8b889de61809e6f32dd2cf7d50e8da
Parents: 11f7e0c
Author: Christopher Collins <cc...@gmail.com>
Authored: Wed Mar 9 14:33:40 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Wed Mar 9 14:33:40 2016 -0800

----------------------------------------------------------------------
 newt/cli/target_cmds.go | 4 ++--
 newt/cli/util.go        | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d2266172/newt/cli/target_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go
index ce8a2b5..23e501a 100644
--- a/newt/cli/target_cmds.go
+++ b/newt/cli/target_cmds.go
@@ -74,7 +74,7 @@ func targetShowCmd(cmd *cobra.Command, args []string) {
 			targetNames = append(targetNames, name)
 		}
 	} else {
-		targetSlice, err := ResolveTargetNames(args...)
+		targetSlice, err := ResolveTargets(args...)
 		if err != nil {
 			NewtUsage(cmd, err)
 		}
@@ -244,7 +244,7 @@ func targetDelCmd(cmd *cobra.Command, args []string) {
 			"target to delete"))
 	}
 
-	targets, err := ResolveTargetNames(args...)
+	targets, err := ResolveTargets(args...)
 	if err != nil {
 		NewtUsage(cmd, err)
 	}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d2266172/newt/cli/util.go
----------------------------------------------------------------------
diff --git a/newt/cli/util.go b/newt/cli/util.go
index 67eabfb..3803343 100644
--- a/newt/cli/util.go
+++ b/newt/cli/util.go
@@ -100,7 +100,7 @@ func ResolveTarget(name string) *target.Target {
 	return nil
 }
 
-func ResolveTargetNames(names ...string) ([]*target.Target, error) {
+func ResolveTargets(names ...string) ([]*target.Target, error) {
 	targets := []*target.Target{}
 
 	for _, name := range names {


[2/2] incubator-mynewt-newt git commit: Add -o option: tees log output to a file.

Posted by cc...@apache.org.
Add -o option: tees log output to a file.


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/6d5c2182
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/6d5c2182
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/6d5c2182

Branch: refs/heads/develop
Commit: 6d5c21828049d9906c2e53ecb1e8bdca28d994f4
Parents: d226617
Author: Christopher Collins <cc...@gmail.com>
Authored: Wed Mar 9 15:17:03 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Wed Mar 9 15:17:03 2016 -0800

----------------------------------------------------------------------
 newt/cli/util.go |  3 ---
 newt/newt.go     |  8 +++++++-
 util/util.go     | 21 +++++++++++++++++----
 3 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/6d5c2182/newt/cli/util.go
----------------------------------------------------------------------
diff --git a/newt/cli/util.go b/newt/cli/util.go
index 3803343..13f7631 100644
--- a/newt/cli/util.go
+++ b/newt/cli/util.go
@@ -36,9 +36,6 @@ import (
 const TARGET_KEYWORD_ALL string = "all"
 const TARGET_DEFAULT_DIR string = "targets"
 
-var Logger *log.Logger
-var OK_STRING = " ok!\n"
-
 func NewtUsage(cmd *cobra.Command, err error) {
 	if err != nil {
 		sErr := err.(*util.NewtError)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/6d5c2182/newt/newt.go
----------------------------------------------------------------------
diff --git a/newt/newt.go b/newt/newt.go
index 405dcce..4f53f83 100644
--- a/newt/newt.go
+++ b/newt/newt.go
@@ -34,6 +34,7 @@ var NewtLogLevel string = ""
 var newtSilent bool
 var newtQuiet bool
 var newtVerbose bool
+var newtLogFile string
 
 func newtCmd() *cobra.Command {
 	newtHelpText := cli.FormatHelp(`Newt allows you to create your own embedded 
@@ -68,7 +69,10 @@ func newtCmd() *cobra.Command {
 				verbosity = util.VERBOSITY_VERBOSE
 			}
 
-			util.Init(NewtLogLevel, verbosity)
+			err := util.Init(NewtLogLevel, verbosity, newtLogFile)
+			if err != nil {
+				cli.NewtUsage(nil, err)
+			}
 		},
 		Run: func(cmd *cobra.Command, args []string) {
 			cmd.Help()
@@ -83,6 +87,8 @@ func newtCmd() *cobra.Command {
 		"Be silent; don't output anything.")
 	newtCmd.PersistentFlags().StringVarP(&NewtLogLevel, "loglevel", "l",
 		"WARN", "Log level, defaults to WARN.")
+	newtCmd.PersistentFlags().StringVarP(&newtLogFile, "outfile", "o",
+		"", "Filename to tee log output to")
 
 	versHelpText := cli.FormatHelp(`Display the Newt version number.`)
 	versHelpEx := "  newt version"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/6d5c2182/util/util.go
----------------------------------------------------------------------
diff --git a/util/util.go b/util/util.go
index cd37c44..a7d1a68 100644
--- a/util/util.go
+++ b/util/util.go
@@ -22,6 +22,7 @@ package util
 import (
 	"bufio"
 	"fmt"
+	"io"
 	"io/ioutil"
 	"log"
 	"os"
@@ -39,9 +40,7 @@ import (
 	"mynewt.apache.org/newt/viper"
 )
 
-var Logger *log.Logger
 var Verbosity int
-var OK_STRING = " ok!\n"
 
 func ParseEqualsPair(v string) (string, string, error) {
 	s := strings.Split(v, "=")
@@ -156,20 +155,34 @@ func Max(x, y int) int {
 }
 
 // Initialize the util module
-func Init(level string, verbosity int) {
+func Init(level string, verbosity int, logFile string) error {
 	if level == "" {
 		level = "WARN"
 	}
 
+	var writer io.Writer
+	if logFile == "" {
+		writer = os.Stderr
+	} else {
+		f, err := os.Create(logFile)
+		if err != nil {
+			return NewNewtError(err.Error())
+		}
+
+		writer = io.MultiWriter(os.Stderr, f)
+	}
+
 	filter := &logutils.LevelFilter{
 		Levels: []logutils.LogLevel{"DEBUG", "VERBOSE", "INFO",
 			"WARN", "ERROR"},
 		MinLevel: logutils.LogLevel(level),
-		Writer:   os.Stderr,
+		Writer:   writer,
 	}
 
 	log.SetOutput(filter)
 	Verbosity = verbosity
+
+	return nil
 }
 
 // Read in the configuration file specified by name, in path