Skip to content

Commit

Permalink
Merge pull request #122 from ewirch/add-autopaho-clientconfig-pahoerrors
Browse files Browse the repository at this point in the history
Add autopaho clientconfig pahoerrors
  • Loading branch information
MattBrittan authored Mar 12, 2023
2 parents d63b3b2 + cd42d2d commit 81fee5f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions autopaho/auto.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ type ClientConfig struct {
OnConnectionUp func(*ConnectionManager, *paho.Connack) // Called (within a goroutine) when a connection is made (including reconnection). Connection Manager passed to simplify subscriptions.
OnConnectError func(error) // Called (within a goroutine) whenever a connection attempt fails

Debug paho.Logger // By default set to NOOPLogger{},set to a logger for debugging info
PahoDebug paho.Logger // debugger passed to the paho package (will default to NOOPLogger{})
Debug paho.Logger // By default set to NOOPLogger{},set to a logger for debugging info
PahoDebug paho.Logger // debugger passed to the paho package (will default to NOOPLogger{})
PahoErrors paho.Logger // error logger passed to the paho package (will default to NOOPLogger{})

connectUsername string
connectPassword []byte
Expand All @@ -66,7 +67,7 @@ type ClientConfig struct {
connectPacketBuilder func(*paho.Connect) *paho.Connect

// We include the full paho.ClientConfig in order to simplify moving between the two packages.
// Note that that Conn will be ignored.
// Note that Conn will be ignored.
paho.ClientConfig
}

Expand Down Expand Up @@ -216,6 +217,10 @@ func NewConnection(ctx context.Context, cfg ClientConfig) (*ConnectionManager, e
cli.SetDebugLogger(cfg.PahoDebug)
}

if cfg.PahoErrors != nil {
cli.SetErrorLogger(cfg.PahoErrors)
}

if cfg.OnConnectionUp != nil {
cfg.OnConnectionUp(&c, connAck)
}
Expand Down

0 comments on commit 81fee5f

Please sign in to comment.