Update .logista.yaml to match the actual log structure

- Fix timestamp field from timestamp to ts
- Add proper packet structure parsing based on sample logs
- Add special visualization for Node Info packets
- Add special visualization for Telemetry packets with DeviceMetrics
- Format uptime in human-readable hours
- Add fallback for unknown packet types with pretty printing
- Handle both packet and non-packet log entries
This commit is contained in:
Daniel Pupius
2025-04-21 12:43:23 -07:00
parent 1c96f0b9f4
commit 35cefa9981

View File

@@ -1,36 +1,88 @@
# Meshstream Logista Configuration
# {"level":"info","ts":1745264398.907407,"logger":"main.server","caller":"meshstream/main.go:88","msg":"Starting server on localhost:8080"}
# {"level":"info","ts":1745264404.905592,"logger":"main.mqtt.MessageLogger","caller":"mqtt/subscriber.go:82","msg":"[NODEINFO_APP] Gateway:!fa74d32c Message type: NODEINFO_APP","packet":{"ChannelID":"MediumSlow","GatewayID":"!fa74d32c","ID":1512657627,"From":4201960236,"To":144028282,"HopLimit":4,"HopStart":0,"WantACK":false,"Priority":"BACKGROUND","ViaMQTT":false,"NextHop":0,"RelayNode":0,"PortNum":4,"Payload":{"id":"!fa74d32c","long_name":"MeshLager","short_name":"🍺","macaddr":"9BL6dNMs","hw_model":44},"RequestID":0,"ReplyID":0,"Emoji":0,"Dest":0,"Source":0,"WantResponse":true,"DecodeError":null,"FullTopic":"msh/US/bayarea/2/c/MediumSlow/!fa74d32c","RegionPath":"US/bayarea","Version":"2","Format":"c","Channel":"MediumSlow","UserID":"!fa74d32c"}}
# {"level":"info","ts":1745264405.2398899,"logger":"main.mqtt.MessageLogger","caller":"mqtt/subscriber.go:82","msg":"[TELEMETRY_APP] Gateway:!eb976cd5 Telemetry: device","packet":{"ChannelID":"MediumSlow","GatewayID":"!eb976cd5","ID":2022965751,"From":3149439480,"To":4294967295,"HopLimit":3,"HopStart":3,"WantACK":false,"Priority":"UNSET","ViaMQTT":false,"NextHop":0,"RelayNode":0,"PortNum":67,"Payload":{"time":1745264403,"Variant":{"DeviceMetrics":{"battery_level":100,"voltage":4.19,"channel_utilization":13.37,"air_util_tx":2.5811112,"uptime_seconds":771327}}},"RequestID":0,"ReplyID":0,"Emoji":0,"Dest":0,"Source":0,"WantResponse":false,"DecodeError":null,"FullTopic":"msh/US/bayarea/2/e/MediumSlow/!eb976cd5","RegionPath":"US/bayarea","Version":"2","Format":"e","Channel":"MediumSlow","UserID":"!eb976cd5"}}
format: |
{{ $timestamp := .timestamp | date | color "blue" }}
{{ $timestamp := .ts | date | color "blue" }}
{{ $level := .level | colorByLevel .level | bold }}
{{ $logger := .logger | dim }}
{{ $message := .msg }}
{{ $timestamp }} {{ $level }} [{{ $logger }}] {{ $message }}
{{- if .from }}
{{ "From:" | dim }} {{ .from }} {{ "To:" | dim }} {{ .to -}}
{{- if .portNum }} {{ "Type:" | dim }} {{ .portNum | color "magenta" }}{{ end -}}
{{- if .channel }} {{ "Channel:" | dim }} {{ .channel | color "green" }}{{ end -}}
{{- if .gateway }} {{ "Gateway:" | dim }} {{ .gateway | color "yellow" }}{{ end }}
{{- if .packet }}
{{- $packet := .packet }}
{{ "Channel:" | dim }} {{ $packet.Channel | color "green" }}
{{ "From:" | dim }} {{ $packet.From }} {{ "To:" | dim }} {{ $packet.To }}
{{ "Type:" | dim }} {{ $packet.PortNum | color "magenta" }}
{{ "Gateway:" | dim }} {{ $packet.GatewayID | color "yellow" }}
{{ "Priority:" | dim }} {{ $packet.Priority }}
{{- if $packet.HopLimit }}
{{ "Hop:" | dim }} {{ $packet.HopStart }}/{{ $packet.HopLimit }}
{{- end }}
{{- if eq .level "error" }}
{{ if .error }}{{ .error | color "red" }}{{ end }}
{{- if $packet.DecodeError }}
{{ "Error:" | dim }} {{ $packet.DecodeError | color "red" }}
{{- end }}
{{- if .message }}
{{ "Message:" | dim }} {{ .message }}
{{- if eq $packet.PortNum 0 }}
{{ "Text Message:" | dim }} {{ if $packet.Payload }}{{ $packet.Payload | color "cyan" }}{{ end }}
{{- end }}
{{- if and .latitude .longitude }}
{{ "Position:" | dim }} {{ .latitude }}, {{ .longitude }}{{ if .altitude }} Alt: {{ .altitude }}m{{ end }}
{{- if eq $packet.PortNum 4 }}
{{ "Node Info:" | dim }}
{{- if $packet.Payload.long_name }} Name: {{ $packet.Payload.long_name }}{{ end }}
{{- if $packet.Payload.short_name }} Short: {{ $packet.Payload.short_name }}{{ end }}
{{- if $packet.Payload.id }} ID: {{ $packet.Payload.id }}{{ end }}
{{- if $packet.Payload.hw_model }} HW: {{ $packet.Payload.hw_model }}{{ end }}
{{- end }}
{{- if or .temperature .batteryLevel .voltage }}
{{ "Telemetry:" | dim }}{{ if .temperature }} Temp: {{ .temperature }}°C{{ end }}{{ if .batteryLevel }} Battery: {{ .batteryLevel }}%{{ end }}{{ if .voltage }} Voltage: {{ .voltage }}V{{ end }}
{{- if eq $packet.PortNum 67 }}
{{ "Telemetry:" | dim }}
{{- if $packet.Payload.Variant.DeviceMetrics }}
{{- $metrics := $packet.Payload.Variant.DeviceMetrics }}
{{- if $metrics.battery_level }} Battery: {{ $metrics.battery_level }}%{{ end }}
{{- if $metrics.voltage }} Voltage: {{ $metrics.voltage }}V{{ end }}
{{- if $metrics.channel_utilization }} Chan Util: {{ $metrics.channel_utilization }}%{{ end }}
{{- if $metrics.air_util_tx }} Air Util: {{ $metrics.air_util_tx }}%{{ end }}
{{- if $metrics.uptime_seconds }} Uptime: {{ $metrics.uptime_seconds | mult 0.000277778 | printf "%.1f hrs" }}{{ end }}
{{- end }}
{{ filter . "timestamp" "level" "logger" "msg" "error" "from" "to" "portNum" "channel" "gateway" "message" "latitude" "longitude" "altitude" "temperature" "batteryLevel" "voltage" | table }}
{{- if $packet.Payload.Variant.EnvironmentMetrics }}
{{- $env := $packet.Payload.Variant.EnvironmentMetrics }}
{{- if $env.temperature }} Temp: {{ $env.temperature }}°C{{ end }}
{{- if $env.relative_humidity }} Humidity: {{ $env.relative_humidity }}%{{ end }}
{{- if $env.barometric_pressure }} Pressure: {{ $env.barometric_pressure }}hPa{{ end }}
{{- end }}
{{- end }}
{{- if eq $packet.PortNum 1 }}
{{ "Position:" | dim }}
{{- if $packet.Payload.latitude_i }} Lat: {{ index $packet.Payload "latitude_i" | mult 0.0000001 | printf "%.6f" }}{{ end }}
{{- if $packet.Payload.longitude_i }} Lon: {{ index $packet.Payload "longitude_i" | mult 0.0000001 | printf "%.6f" }}{{ end }}
{{- if $packet.Payload.altitude }} Alt: {{ $packet.Payload.altitude }}m{{ end }}
{{- end }}
{{- if ne $packet.PortNum 0 }}
{{- if ne $packet.PortNum 1 }}
{{- if ne $packet.PortNum 4 }}
{{- if ne $packet.PortNum 67 }}
{{ "Payload:" | dim }}
{{ $packet.Payload | pretty }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ if not .packet }}
{{ filter . "level" "ts" "logger" "caller" "msg" | table }}
{{ end }}
# Date formatting
date_format: "15:04:05.000"