Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengees committed Jul 5, 2021
1 parent c856f89 commit e3fe8fe
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class MqttAutoConfiguration {
.username(config.username)
.password(config.password.toByteArray())
.applySimpleAuth()
.addConnectedListener { logger.info("Connected to broker.") }
.addDisconnectedListener {
if (it.reconnector.isReconnect) {
logger.warn("Disconnected from broker, reconnecting...")
} else {
logger.info("Disconnected from broker.")
}
}

val builder = if (config.ssl) {
baseClient.sslWithDefaultConfig()
Expand All @@ -56,8 +64,6 @@ class MqttAutoConfiguration {
if (acknowledgement.returnCode.isError) {
throw BrokerConnectException(acknowledgement)
} else {
logger.info("Successfully connected to broker.")

return DisposableMqtt3Client(client)
}
} catch (e: TimeoutException) {
Expand Down

0 comments on commit e3fe8fe

Please sign in to comment.