- Tauri v2 + Vue 3 + TypeScript + Element Plus
- Connection management (CRUD + enable/disable/test)
- Preset system with {{variable}} placeholders
- Dashboard with live message scrolling + topic tree
- Payload inspector (JSON/Hex/Base64/Plain)
- Protocol-level logging (file + UI dual channel)
- Global variable manager with localStorage persistence
- MQTT v5 property support (user properties, content type, etc.)
- SubAck result tracking with subscribe_tracked API
46 lines
922 B
TypeScript
46 lines
922 B
TypeScript
import { ref } from 'vue'
|
|
|
|
export interface LogEntry {
|
|
id: string
|
|
timestamp: number
|
|
connectionId: string
|
|
level: 'info' | 'warn' | 'error'
|
|
event: string
|
|
message: string
|
|
details?: string
|
|
}
|
|
|
|
const MAX_LOGS = 1000
|
|
|
|
const logs = ref<LogEntry[]>([])
|
|
|
|
export function useLogs() {
|
|
function push(entry: LogEntry) {
|
|
logs.value.push(entry)
|
|
if (logs.value.length > MAX_LOGS) {
|
|
logs.value.splice(0, logs.value.length - MAX_LOGS)
|
|
}
|
|
}
|
|
|
|
function clear() {
|
|
logs.value = []
|
|
}
|
|
|
|
function filterByConnection(connectionId: string): LogEntry[] {
|
|
if (!connectionId) return logs.value
|
|
return logs.value.filter((l) => l.connectionId === connectionId)
|
|
}
|
|
|
|
function filterByLevel(level: string): LogEntry[] {
|
|
if (!level) return logs.value
|
|
return logs.value.filter((l) => l.level === level)
|
|
}
|
|
|
|
return {
|
|
logs,
|
|
push,
|
|
clear,
|
|
filterByConnection,
|
|
filterByLevel,
|
|
}
|
|
} |