Skip to content

Instantly share code, notes, and snippets.

@mill1000
Created March 9, 2021 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mill1000/8ae57b9c6ecc499f1f999f03191862f7 to your computer and use it in GitHub Desktop.
Save mill1000/8ae57b9c6ecc499f1f999f03191862f7 to your computer and use it in GitHub Desktop.
Simple ESP32 log wrapper that adds function name and line number to output
#ifndef __LOG__
#define __LOG__
#include "esp_log.h"
#define __FORMAT(FORMAT) "(%s:%d) " FORMAT
#define LOGD(TAG, FORMAT, ...) ESP_LOGD(TAG, __FORMAT(FORMAT), __func__, __LINE__, ##__VA_ARGS__)
#define LOGI(TAG, FORMAT, ...) ESP_LOGI(TAG, __FORMAT(FORMAT), __func__, __LINE__, ##__VA_ARGS__)
#define LOGW(TAG, FORMAT, ...) ESP_LOGW(TAG, __FORMAT(FORMAT), __func__, __LINE__, ##__VA_ARGS__)
#define LOGE(TAG, FORMAT, ...) ESP_LOGE(TAG, __FORMAT(FORMAT), __func__, __LINE__, ##__VA_ARGS__)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment