Repository: incubator-mynewt-newtmgr
Updated Branches:
  refs/heads/master e5dcf07e4 -> 5fce9f8d2


nmxutil - allow log level to be configured


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

Branch: refs/heads/master
Commit: 5fce9f8d2a14c7d96c54f9ddf7a58423fbda8b7d
Parents: e5dcf07
Author: Christopher Collins <ccoll...@apache.org>
Authored: Tue Apr 11 12:14:36 2017 -0700
Committer: Christopher Collins <ccoll...@apache.org>
Committed: Tue Apr 11 12:14:36 2017 -0700

----------------------------------------------------------------------
 newtmgr/cli/commands.go             |  4 +++-
 nmxact/example/ble_dual/ble_dual.go |  2 +-
 nmxact/nmble/ble_fsm.go             | 11 ++---------
 nmxact/nmxutil/nmxutil.go           | 14 ++++++++++++++
 4 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/5fce9f8d/newtmgr/cli/commands.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/commands.go b/newtmgr/cli/commands.go
index d0ab758..72f4999 100644
--- a/newtmgr/cli/commands.go
+++ b/newtmgr/cli/commands.go
@@ -23,8 +23,9 @@ import (
        log "github.com/Sirupsen/logrus"
        "github.com/spf13/cobra"
 
-       "mynewt.apache.org/newtmgr/newtmgr/nmutil"
        "mynewt.apache.org/newt/util"
+       "mynewt.apache.org/newtmgr/newtmgr/nmutil"
+       "mynewt.apache.org/newtmgr/nmxact/nmxutil"
 )
 
 var NewtmgrLogLevel log.Level
@@ -45,6 +46,7 @@ func Commands() *cobra.Command {
                        if err != nil {
                                nmUsage(nil, err)
                        }
+                       nmxutil.SetLogLevel(NewtmgrLogLevel)
                },
                Run: func(cmd *cobra.Command, args []string) {
                        cmd.HelpFunc()(cmd, args)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/5fce9f8d/nmxact/example/ble_dual/ble_dual.go
----------------------------------------------------------------------
diff --git a/nmxact/example/ble_dual/ble_dual.go 
b/nmxact/example/ble_dual/ble_dual.go
index 7a43b45..958aaa1 100644
--- a/nmxact/example/ble_dual/ble_dual.go
+++ b/nmxact/example/ble_dual/ble_dual.go
@@ -99,7 +99,7 @@ func main() {
        params := nmble.NewXportCfg()
        params.SockPath = "/tmp/blehostd-uds"
        params.BlehostdPath = "blehostd.elf"
-       params.DevPath = "/dev/cu.usbmodem141121"
+       params.DevPath = "/dev/cu.usbmodem14221"
 
        x, err := nmble.NewBleXport(params)
        if err != nil {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/5fce9f8d/nmxact/nmble/ble_fsm.go
----------------------------------------------------------------------
diff --git a/nmxact/nmble/ble_fsm.go b/nmxact/nmble/ble_fsm.go
index 19f626d..ef5e69d 100644
--- a/nmxact/nmble/ble_fsm.go
+++ b/nmxact/nmble/ble_fsm.go
@@ -3,7 +3,6 @@ package nmble
 import (
        "encoding/hex"
        "fmt"
-       "os"
        "path"
        "runtime"
        "sync"
@@ -24,12 +23,6 @@ func getNextId() uint32 {
        return atomic.AddUint32(&nextId, 1) - 1
 }
 
-var listenLog = &log.Logger{
-       Out:       os.Stderr,
-       Formatter: new(log.TextFormatter),
-       Level:     log.InfoLevel,
-}
-
 const DFLT_ATT_MTU = 23
 
 type BleSesnState int32
@@ -140,7 +133,7 @@ func (bf *BleFsm) addBleListener(name string, base 
BleMsgBase) (
 
        _, file, line, _ := runtime.Caller(2)
        file = path.Base(file)
-       listenLog.Debugf("[%d] {add-listener}    [%s:%d] %s: base=%+v",
+       nmxutil.ListenLog.Debugf("[%d] {add-listener}    [%s:%d] %s: base=%+v",
                bf.id, file, line, name, base)
 
        bl := NewBleListener()
@@ -177,7 +170,7 @@ func (bf *BleFsm) addBleSeqListener(name string, seq 
BleSeq) (
 func (bf *BleFsm) removeBleListener(name string, base BleMsgBase) {
        _, file, line, _ := runtime.Caller(2)
        file = path.Base(file)
-       listenLog.Debugf("[%d] {remove-listener} [%s:%d] %s: base=%+v",
+       nmxutil.ListenLog.Debugf("[%d] {remove-listener} [%s:%d] %s: base=%+v",
                bf.id, file, line, name, base)
 
        bf.blsMtx.Lock()

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newtmgr/blob/5fce9f8d/nmxact/nmxutil/nmxutil.go
----------------------------------------------------------------------
diff --git a/nmxact/nmxutil/nmxutil.go b/nmxact/nmxutil/nmxutil.go
index e63a7e2..4b232e9 100644
--- a/nmxact/nmxutil/nmxutil.go
+++ b/nmxact/nmxutil/nmxutil.go
@@ -2,14 +2,28 @@ package nmxutil
 
 import (
        "math/rand"
+       "os"
        "sync"
        "time"
+
+       log "github.com/Sirupsen/logrus"
 )
 
 var nextNmpSeq uint8
 var beenRead bool
 var seqMutex sync.Mutex
 
+var ListenLog = &log.Logger{
+       Out:       os.Stderr,
+       Formatter: new(log.TextFormatter),
+       Level:     log.DebugLevel,
+}
+
+func SetLogLevel(level log.Level) {
+       log.SetLevel(level)
+       ListenLog.Level = level
+}
+
 func NextNmpSeq() uint8 {
        seqMutex.Lock()
        defer seqMutex.Unlock()

Reply via email to