How to fix ESP32 ESP_LOGI(...) error: expected ')' before 'msg'

Problem:

You have code in your project such as

ESP_LOGI("MyTag", msg);

where msg is a const char*, but the project fails to compile with an error message such as

src/main.cpp:280:26: error: expected ')' before 'msg'
  280 |         ESP_LOGI("MyTag", msg);

Solution

The format parameter can’t be any string but needs to be a string constant. Replace your code by

ESP_LOGI("MyTag", "%s", msg);