Skip to content

Commit

Permalink
feat(desktop): log info improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream committed Oct 16, 2024
1 parent c7ba20a commit fe820fe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/components/widgets/TreeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<template #default="{ node, data }">
<span class="custom-tree-node">
<span class="tree-node-info">
<span>{{ node.label }}</span>
<span v-if="data.connectionInfo && data.connectionInfo.name">
&nbsp;- [{{ data.connectionInfo.name }}]
<span>
<span v-if="data.connectionInfo && data.connectionInfo.name">{{ data.connectionInfo.name }}@</span
>{{ node.label }}
</span>
<el-tag v-if="!checkPayloadEmpty(data.latestMessage)" size="mini" class="value-tag ml-2">
{{ data.latestMessage }}
Expand Down
34 changes: 20 additions & 14 deletions src/views/connections/ConnectionsDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ export default class ConnectionsDetail extends Vue {
clearInterval(this.sendTimeId)
this.sendTimeId = null
this.$message.success(this.$tc('connections.stopTimedMessage'))
this.$log.info(`Timed messages sending stopped for ${this.record.name}`)
this.$log.info(`Timed messages sending stopped for ${this.record.name}@${this.record.host}`)
}
}
Expand Down Expand Up @@ -977,7 +977,7 @@ export default class ConnectionsDetail extends Vue {
if (this.record.id) {
const { messageService } = useServices()
await messageService.cleanInConnection(this.record.id)
this.$log.info(`History connection messages were cleaned for ${this.record.name}`)
this.$log.info(`History connection messages were cleaned for ${this.record.name}@${this.record.host}`)
}
}
Expand Down Expand Up @@ -1085,7 +1085,7 @@ export default class ConnectionsDetail extends Vue {
})
this.setShowClientInfo(false)
this.$emit('reload', false, false, this.handleReSubTopics)
this.$log.info(`Successful connection for ${this.record.name}, MQTT.js onConnect trigger`)
this.$log.info(`Successful connection for ${this.record.name}@${this.record.host}, MQTT.js onConnect trigger`)
}
// Error callback
Expand All @@ -1096,7 +1096,9 @@ export default class ConnectionsDetail extends Vue {
}
this.forceCloseTheConnection()
this.notifyMsgWithCopilot(msgTitle)
this.$log.error(`Connection for ${this.record.name} failed, MQTT.js onError trigger, Error: ${error.stack}`)
this.$log.error(
`Connection for ${this.record.name}@${this.record.host} failed, MQTT.js onError trigger, Error: ${error.stack}`,
)
this.$emit('reload')
}
Expand All @@ -1119,7 +1121,7 @@ export default class ConnectionsDetail extends Vue {
this.forceCloseTheConnection()
} else {
this.$log.info(
`Retrying connection for ${this.record.name}, attempt: [${this.reTryConnectTimes}/${this.maxReconnectTimes}]`,
`Retrying connection for ${this.record.name}@${this.record.host}, attempt: [${this.reTryConnectTimes}/${this.maxReconnectTimes}]`,
)
this.connectLoading = true
this.$notify({
Expand All @@ -1135,7 +1137,7 @@ export default class ConnectionsDetail extends Vue {
// Close connection callback
private onClose() {
this.$log.info(`Connection for ${this.record.name} closed, MQTT.js onClose trigger`)
this.$log.info(`Connection for ${this.record.name}@${this.record.host} closed, MQTT.js onClose trigger`)
this.connectLoading = false
}
Expand Down Expand Up @@ -1221,7 +1223,9 @@ export default class ConnectionsDetail extends Vue {
if (this.client.reconnecting && this.client.connected === false) {
this.client.reconnecting = false
this.forceCloseTheConnection()
this.$log.warn(`MQTTX force stopped reconnecting for ${this.record.name} (Client ID: ${this.record.clientId})`)
this.$log.warn(
`MQTTX force stopped reconnecting for ${this.record.name}@${this.record.host} - Client ID: ${this.record.clientId}`,
)
}
}
Expand Down Expand Up @@ -1258,14 +1262,14 @@ export default class ConnectionsDetail extends Vue {
}
this.setScript({ currentScript })
this.$message.success(this.$tc('script.startScript'))
this.$log.info(`Script set successfully for ${this.record.name}`)
this.$log.info(`Script set successfully for ${this.record.name}@${this.record.host}`)
}
// Remove script
private removeScript() {
this.setScript({ currentScript: null })
this.$message.success(this.$tc('script.stopScirpt'))
this.$log.info(`Script removed successfully from ${this.record.name}`)
this.$log.info(`Script removed successfully from ${this.record.name}@${this.record.host}`)
}
/*
Expand Down Expand Up @@ -1386,9 +1390,11 @@ export default class ConnectionsDetail extends Vue {
const isFromActiveTopic = this.msgType !== 'publish' && this.activeTopic && isActiveTopicMessages
const isFromNotActiveTopic = this.msgType !== 'publish' && !this.activeTopic
if (isFromActiveTopic || isFromNotActiveTopic) {
let receivedLog = `Message arrived for ${this.record.name} with topic: "${topic}". Message ID: "${
message.id
}", payload: ${jsonStringify(message.payload)}. MQTT.js onMessageArrived trigger`
let receivedLog = `Message arrived for ${this.record.name}@${
this.record.host
} with topic: "${topic}". Message ID: "${message.id}", payload: ${jsonStringify(
message.payload,
)}. MQTT.js onMessageArrived trigger`
this.$log.info(receivedLog)
}
} else {
Expand Down Expand Up @@ -1550,7 +1556,7 @@ export default class ConnectionsDetail extends Vue {
private notifyTimedMessageSuccess() {
this.$message.success(`${this.$t('connections.startTimedMessage')}${this.sendFrequency}`)
this.$log.info(
`Timed message for ${this.record.name} started successfully with a frequency of ${this.sendFrequency} seconds.`,
`Timed message for ${this.record.name}@${this.record.host} started successfully with a frequency of ${this.sendFrequency} seconds.`,
)
}
Expand Down Expand Up @@ -1686,7 +1692,7 @@ export default class ConnectionsDetail extends Vue {
this.notifyMsgWithCopilot(errorMsg)
this.stopTimedSend()
this.$log.error(
`Failed to publish message for ${this.record.name}. Error: ${errorMsg}. Stack trace: ${error.stack}`,
`Failed to publish message for ${this.record.name}@${this.record.host}. Error: ${errorMsg}. Stack trace: ${error.stack}`,
)
}
Expand Down
7 changes: 5 additions & 2 deletions src/views/viewer/TopicTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export default class TopicTree extends Vue {
packet,
connectionInfo,
})
this.$log.info(
`Topic Tree: Updated tree data for connection ${connectionInfo.name}@${connectionInfo.host}. Topic: ${packet.topic}, QoS: ${packet.qos}`,
)
this.queueMessage(packet, connectionInfo.id as string)
}
Expand Down Expand Up @@ -80,9 +83,9 @@ export default class TopicTree extends Vue {
try {
const processedMessages = messages.map((m) => this.generateMessage(m))
await messageService.importMsgsToConnection(processedMessages, connectionId)
this.$log.info(`Topic Tree: Processed ${messages.length} messages for connection ${connectionId}`)
this.$log.info(`Topic Tree: Processed and stored ${messages.length} messages for connection ${connectionId}`)
} catch (error) {
this.$log.error(`Topic Tree: Error processing messages: ${(error as Error).toString()}`)
this.$log.error(`Topic Tree: Error processing and storing messages: ${(error as Error).toString()}`)
}
})
}
Expand Down

0 comments on commit fe820fe

Please sign in to comment.