teslamotors / fleet-telemetry

Apache License 2.0
625 stars 66 forks source link

Improve server logging in json format #140

Closed agbpatro closed 3 months ago

agbpatro commented 3 months ago

Description

Fleet telemetry has a config to set server logging in json mode here. However the logs aren't in json format. This PR formats all logs in json format if flag is set

before

time="2024-04-02T18:51:12Z" level=info msg=starting
time="2024-04-02T18:51:12Z" level=info msg=status_server_configured
time="2024-04-02T18:51:12Z" level=info msg=profiler_started
time="2024-04-02T18:51:12Z" level=info msg="registered kafka for namespace: tesla_telemetry"
time="2024-04-02T18:51:12Z" level=info msg="registered pubsub for project: test-project-id, namespace: tesla_telemetry"
time="2024-04-02T18:51:12Z" level=info msg="appending custom CA file :/etc/tesla/certs/server/vehicle_device.CA.cert"

now

{"activity":true,"context":"fleet-telemetry","level":"info","msg":"starting_server","time":"2024-04-02T18:47:00Z"}
{"activity":true,"context":"fleet-telemetry","level":"info","msg":"status_server_configured","time":"2024-04-02T18:47:00Z"}
{"activity":true,"context":"fleet-telemetry","level":"info","msg":"profiler_started","port":4269,"time":"2024-04-02T18:47:00Z"}
{"activity":true,"context":"fleet-telemetry","level":"info","msg":"kafka_registered","namespace":"tesla_telemetry","time":"2024-04-02T18:47:00Z"}
{"activity":true,"context":"fleet-telemetry","level":"info","msg":"pubsub_registerd","namespace":"tesla_telemetry","project":"test-project-id","time":"2024-04-02T18:47:00Z"}
{"activity":true,"ca_file_path":"/etc/tesla/certs/server/vehicle_device.CA.cert","context":"fleet-telemetry","level":"info","msg":"custom_ca_file_appened","time":"2024-04-02T18:47:00Z"}

Fixes # (issue)

Type of change

Please select all options that apply to this change:

Checklist:

Confirm you have completed the following steps: