# 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 := .ts | date | color "blue" -}}
  {{- $level := .level | colorByLevel .level | bold -}}
  {{- $logger := .logger | dim -}}
  {{- $message := .msg -}}

  {{$timestamp }} {{ $level }} [{{ $logger }}] {{ $message }}
  {{if .packet -}}
  {{- $packet := .packet -}}
  {{"Channel:" | dim }} {{ $packet.ChannelID | color "green" }}
  {{ "From:" | dim }} {{ $packet.From | mult 1 }} {{ "To:" | dim }} {{ $packet.To | mult 1 }}
  {{ "Gateway:" | dim }} {{ $packet.GatewayID | color "yellow" }}
  {{ "Priority:" | dim }} {{ $packet.Priority }}
  {{ "PortNum:" | dim }} {{ $packet.PortNum }}

  {{- if $packet.HopLimit }}
  {{ "Hop:" | dim }} {{ $packet.HopStart }}/{{ $packet.HopLimit }}
  {{- end }}
  {{- if $packet.DecodeError }}
  {{ "Error:" | dim }} {{ $packet.DecodeError | color "red" }}
  {{- end }}
  {{ "Payload:" | dim }} 
  {{ $packet.Payload | table }}

  {{end -}}

  {{- if not .packet -}}
  {{- filter . "level" "ts" "logger" "caller" "msg" | table -}}
  {{- end -}}

# Date formatting
date_format: "15:04:05.000"

# Handle non-JSON lines
handle_non_json: true
