# Meshstream Logista Configuration

# {"level":"info","ts":1745264398.907407,"logger":"main.server","caller":"meshstream/main.go:88","msg":"Starting server on localhost:8080"}
# Updated log examples:
# map[caller:mqtt/subscriber.go:83 level:info logger:main.mqtt.MessageLogger msg:[NODEINFO_APP] Gateway:!4358bcb4 Message type: NODEINFO_APP packet:info:{full_topic:"msh/US/bayarea/2/e/LongFast/!4358bcb4"  region_path:"US/bayarea"  version:"2"  format:"e"  channel:"LongFast"  user_id:"!4358bcb4"}  data:{channel_id:"LongFast"  gateway_id:"!4358bcb4"  id:1496068057  from:4228900486  to:902833813  hop_limit:5  hop_start:5  priority:"UNSET"  port_num:NODEINFO_APP  node_info:{id:"!fc0fe686"  long_name:"Meshtastic e686"  short_name:"e686"  macaddr:"\xc1.\xfc\x0f\xe6\x86"  hw_model:TRACKER_T1000_E  role:CLIENT_MUTE  public_key:"\xb3\x82\x08\x0f\x1e\xbc\x1e *\xdc\xf6ZW\x0fナ\x14\xb3\x18Gk<7\x83\x86\xb7\xf5\xf2\xc5J\x01"}  want_response:true} ts:1.745300044594027e+09]

format: |
  {{- $timestamp := .ts | date | color "blue" -}}
  {{- $level := .level | colorByLevel .level | bold -}}
  {{- $logger := .logger | dim -}}
  {{- $message := .msg }}
  {{$timestamp }} {{ $level }} [{{ $logger }}] {{ $message }}
  {{- if .packet -}}
    {{- $info := .packet.info -}}
    {{- $data := .packet.data -}}
    {{- if $info }}
  {{ "Channel:" | dim }} {{ $info.channel | color "green" }}{{ "  Topic:" | dim }} {{ $info.fullTopic | color "cyan" }}
    {{- end }}
    {{- if $data }}
  {{ "From:" | dim }} {{ $data.from | mult 1 }}{{ "  To:" | dim }} {{ $data.to | mult 1 }}{{ "  Gateway:" | dim }} {{ $data.gatewayId | color "yellow" }}
  {{ "Priority:" | dim }} {{ $data.priority }}{{ "  PortNum:" | dim }} {{ $data.portNum }}
      {{- if $data.hopLimit }}{{ "  Hop:" | dim }} {{ $data.hopStart }}/{{ $data.hopLimit }}{{ end }}
      {{- if $data.decodeError }}
  {{ "Error:" | dim }} {{ $data.decodeError | color "red" }}
      {{- end -}}
      {{- if $data.textMessage }}
  {{ "Text:" | dim }} {{ $data.textMessage }}
      {{- else if $data.mapReport }}
  {{ "Map Report:" | dim }}
  {{ $data.mapReport | table }}
      {{- else if $data.routeDiscovery }}
  {{ "Route Discovery:" | dim }}
  {{ $data.routeDiscovery | table }}
      {{- else if $data.position }}
  {{ "Position:" | dim }} Lat: {{ $data.position.latitudeI | mult 0.0000001 }}, Long: {{ $data.position.longitudeI | mult 0.0000001 }}
      {{- else if $data.nodeInfo }}
  {{ "NodeInfo:" | dim }} {{ $data.nodeInfo.id }} {{ $data.nodeInfo.longName }}
      {{- else if $data.telemetry }}
  {{ "Telemetry:" | dim }}
        {{- if $data.telemetry.deviceMetrics }}
    {{ "Battery:" | dim }} {{ $data.telemetry.deviceMetrics.batteryLevel }}%, {{ $data.telemetry.deviceMetrics.voltage }}V
        {{- end }}
        {{- if $data.telemetry.environmentMetrics }}
    {{ "Environment:" | dim }} Temp: {{ $data.telemetry.environmentMetrics.temperature }}°C, Humidity: {{ $data.telemetry.environmentMetrics.relativeHumidity }}%
        {{- end }}
      {{- else }}
  {{ "Payload:" | dim }}
  {{ filter $data "channelId" "gatewayId" "id" "from" "to" "hopLimit" "hopStart" "priority" "portNum" "decodeError" | table }}
      {{- end }}
    {{- else }}
  {{ .packet | table }}
    {{- end }}
  {{- else if .nodeCounts}}
  {{ .nodeCounts | table}}
  {{- else if .portCounts}}
  {{ .portCounts | table}}
  {{- else}}
  {{ filter . "level" "ts" "logger" "caller" "msg" | table }}
  {{- end -}}

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

# Handle non-JSON lines
handle_non_json: true
