summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-08 17:45:39 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-08 17:45:39 +0100
commit1f754944c23df02b64aeb591d502b36ad314c5eb (patch)
treec6d624474a6bce0a63e1460d2acb83978caf715e
parentb6049d0b616812bc72d0549d88cc59f21d517b7c (diff)
Log projects events.
-rw-r--r--.vscode/launch.json2
-rw-r--r--cmd-exec.go10
2 files changed, 11 insertions, 1 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 6978301..d85db0e 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -62,7 +62,7 @@
"XDS_LOGLEVEL": "debug"
},
"args": ["exec",
- "-id", "IW7B4EE-DBY4Z74_Agent-TCF",
+ "-id", "3baf",
"-rpath", "build",
"pwd && ls .."
],
diff --git a/cmd-exec.go b/cmd-exec.go
index 1d121c3..c02496b 100644
--- a/cmd-exec.go
+++ b/cmd-exec.go
@@ -61,6 +61,7 @@ func exec(ctx *cli.Context) error {
exitChan := make(chan exitResult, 1)
IOsk.On("disconnection", func(err error) {
+ Log.Debugf("WS disconnection event with err: %v\n", err)
exitChan <- exitResult{err, 2}
})
@@ -85,6 +86,15 @@ func exec(ctx *cli.Context) error {
exitChan <- exitResult{ev.Error, ev.Code}
})
+ IOsk.On(apiv1.EVTProjectChange, func(ev apiv1.EventMsg) {
+ prj, _ := ev.DecodeProjectConfig()
+ Log.Infof("Event %v (%v): %v", ev.Type, ev.Time, prj)
+ })
+ evReg := apiv1.EventRegisterArgs{Name: apiv1.EVTProjectChange}
+ if err := HTTPCli.Post("/events/register", &evReg, nil); err != nil {
+ return cli.NewExitError(err, 1)
+ }
+
// Retrieve the project definition
prj := apiv1.ProjectConfig{}
if err := HTTPCli.Get("/projects/"+prjID, &prj); err != nil {