@@ -2,22 +2,25 @@ package command
2
2
3
3
import (
4
4
"fmt"
5
- paho "github.com/eclipse/paho.mqtt.golang"
6
- "github.com/spf13/cobra"
7
- "github.com/zmoog/mariquita/adapters/mqtt"
8
- "github.com/zmoog/mariquita/internal/properties"
5
+ "log"
9
6
"math/rand"
10
7
"os"
11
8
"os/signal"
12
9
"syscall"
13
10
"time"
11
+
12
+ paho "github.com/eclipse/paho.mqtt.golang"
13
+ "github.com/spf13/cobra"
14
+ "github.com/zmoog/mariquita/adapters/mqtt"
15
+ "github.com/zmoog/mariquita/internal/properties"
14
16
)
15
17
16
18
var (
17
- host string
18
- username string
19
- password string
20
- thingID string
19
+ host string
20
+ username string
21
+ password string
22
+ thingID string
23
+ troubleshooting bool
21
24
)
22
25
23
26
func init () {
@@ -26,6 +29,8 @@ func init() {
26
29
pingCommand .Flags ().StringVarP (& password , "password" , "p" , "" , "Password (required)" )
27
30
pingCommand .Flags ().StringVarP (& thingID , "thing_id" , "t" , "" , "Thing ID (required)" )
28
31
32
+ pingCommand .Flags ().BoolVar (& troubleshooting , "troubleshooting" , false , "Enable troubleshooting mode (full logs from the MQTT client)" )
33
+
29
34
pingCommand .MarkFlagRequired ("username" )
30
35
pingCommand .MarkFlagRequired ("password" )
31
36
pingCommand .MarkFlagRequired ("thing_id" )
@@ -38,6 +43,14 @@ var pingCommand = &cobra.Command{
38
43
Short : "Ping Arduino IoT Cloud" ,
39
44
Long : "Ping Arduino IoT Cloud" ,
40
45
RunE : func (cmd * cobra.Command , args []string ) error {
46
+
47
+ if troubleshooting {
48
+ paho .ERROR = log .New (os .Stdout , "[ERROR] " , 0 )
49
+ paho .CRITICAL = log .New (os .Stdout , "[CRIT] " , 0 )
50
+ paho .WARN = log .New (os .Stdout , "[WARN] " , 0 )
51
+ paho .DEBUG = log .New (os .Stdout , "[DEBUG] " , 0 )
52
+ }
53
+
41
54
mqttAdapter := mqtt .NewAdapterWithAuth (
42
55
host ,
43
56
username ,
0 commit comments