Add Logista for JSON log processing

- Add .logista.yaml configuration for prettier log output
- Add github.com/dpup/logista as a go tool
- Update Makefile run target to pipe output through logista
- Configure the format to show timestamp, level, and message with colors
- Add special formatting for different message types
- Display telemetry and position data in readable format
- Add table display for remaining structured fields
This commit is contained in:
Daniel Pupius
2025-04-21 11:56:31 -07:00
parent 0f151c31b9
commit 1c96f0b9f4
3 changed files with 46 additions and 2 deletions
+39
View File
@@ -0,0 +1,39 @@
# Meshstream Logista Configuration
format: |
{{ $timestamp := .timestamp | 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 }}
{{- end }}
{{- if eq .level "error" }}
{{ if .error }}{{ .error | color "red" }}{{ end }}
{{- end }}
{{- if .message }}
{{ "Message:" | dim }} {{ .message }}
{{- end }}
{{- if and .latitude .longitude }}
{{ "Position:" | dim }} {{ .latitude }}, {{ .longitude }}{{ if .altitude }} Alt: {{ .altitude }}m{{ 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 }}
{{- end }}
{{ filter . "timestamp" "level" "logger" "msg" "error" "from" "to" "portNum" "channel" "gateway" "message" "latitude" "longitude" "altitude" "temperature" "batteryLevel" "voltage" | table }}
# Date formatting
date_format: "15:04:05.000"
# Handle non-JSON lines
handle_non_json: true
+2 -2
View File
@@ -12,9 +12,9 @@ build:
mkdir -p dist
go build -o dist/meshstream
# Run the application
# Run the application with json log formatting
run: build
./dist/meshstream
./dist/meshstream 2>&1 | go tool github.com/dpup/logista
# Generate Go code from Protocol Buffers
gen-proto: tools
+5
View File
@@ -2,6 +2,11 @@ module meshstream
go 1.24.1
// Add logista as a go tool
toolchain go1.24.1
tool github.com/dpup/logista v1.0.7
require (
github.com/eclipse/paho.mqtt.golang v1.5.0
google.golang.org/protobuf v1.36.6