stanleyhuangyc / Freematics

Official source code repository for Freematics
https://freematics.com
419 stars 345 forks source link

Write log messages to SD card #163

Open tobiasschuerg opened 2 years ago

tobiasschuerg commented 2 years ago

It would help debugging if logs could be written to SD card. A rolling log file of the last few days would be enough.

ankostis commented 2 years ago

That's not easy/small feat to do it right:

  1. Need to replace all Serial.print statements with ESP_LOG() ones.
  2. Switch from ArduinoCore's to ESP_IDF logging system on which you may reconfigure destinations. (This blog explains why there are 2 logging systems)
  3. Write code to replace log-sink and send it to SD or the network (in addition to the serial).

I have done that to my fork, check all commits with "LogSink", "MLog" and "Logs OVUNQUE" in their commit-message, and c2f69ebc5 where the switch-og-logging-subsystem happened.