forked from me-no-dev/ESPAsyncWebServer
-
Notifications
You must be signed in to change notification settings - Fork 63
Logging refactoring to supports macros redefinition and -D USE_ESP_IDF_LOG #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+244
−121
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,12 @@ build_flags = | |
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1 | ||
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096 | ||
; -D CONFIG_ASYNC_TCP_USE_WDT=0 | ||
; -D CONFIG_ARDUHAL_LOG_COLORS | ||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE | ||
; -D USE_ESP_IDF_LOG=1 | ||
; -D TAG=\"core\" | ||
; -D LOG_LOCAL_LEVEL=ESP_LOG_VERBOSE | ||
; -D ASYNCWEBSERVER_LOG_DEBUG | ||
upload_protocol = esptool | ||
monitor_speed = 115200 | ||
monitor_filters = esp32_exception_decoder, log2file | ||
|
@@ -135,6 +141,20 @@ board = ${sysenv.PIO_BOARD} | |
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20-rc2/platform-espressif32.zip | ||
board = ${sysenv.PIO_BOARD} | ||
|
||
[env:ci-arduino-2-esp-idf-log] | ||
platform = [email protected] | ||
board = ${sysenv.PIO_BOARD} | ||
build_flags = | ||
${env.build_flags} | ||
-D USE_ESP_IDF_LOG=1 | ||
-D TAG=\"core\" | ||
|
||
[env:ci-arduino-3-esp-idf-log] | ||
board = ${sysenv.PIO_BOARD} | ||
build_flags = | ||
${env.build_flags} | ||
-D USE_ESP_IDF_LOG=1 | ||
|
||
[env:ci-arduino-3-no-json] | ||
board = ${sysenv.PIO_BOARD} | ||
lib_deps = | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov | ||
|
||
#pragma once | ||
|
||
#ifdef ASYNCWEBSERVER_LOG_CUSTOM | ||
// The user must provide the following macros in AsyncWebServerLoggingCustom.h: | ||
// async_ws_log_e, async_ws_log_w, async_ws_log_i, async_ws_log_d, async_ws_log_v | ||
#include <AsyncWebServerLoggingCustom.h> | ||
|
||
#elif defined(ASYNCWEBSERVER_LOG_DEBUG) | ||
// Local Debug logging | ||
#include <HardwareSerial.h> | ||
#define async_ws_log_e(format, ...) Serial.printf("E async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#define async_ws_log_w(format, ...) Serial.printf("W async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#define async_ws_log_i(format, ...) Serial.printf("I async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#define async_ws_log_d(format, ...) Serial.printf("D async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#define async_ws_log_v(format, ...) Serial.printf("V async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
|
||
#else | ||
// Framework-based logging | ||
|
||
/** | ||
* LibreTiny specific configurations | ||
*/ | ||
#if defined(LIBRETINY) | ||
#include <Arduino.h> | ||
#define async_ws_log_e(format, ...) log_e(format, ##__VA_ARGS__) | ||
#define async_ws_log_w(format, ...) log_w(format, ##__VA_ARGS__) | ||
#define async_ws_log_i(format, ...) log_i(format, ##__VA_ARGS__) | ||
#define async_ws_log_d(format, ...) log_d(format, ##__VA_ARGS__) | ||
#define async_ws_log_v(format, ...) log_v(format, ##__VA_ARGS__) | ||
|
||
/** | ||
* Raspberry Pi Pico specific configurations | ||
*/ | ||
#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350) | ||
#include <HardwareSerial.h> | ||
// define log levels | ||
#define ASYNC_WS_LOG_NONE 0 /*!< No log output */ | ||
#define ASYNC_WS_LOG_ERROR 1 /*!< Critical errors, software module can not recover on its own */ | ||
#define ASYNC_WS_LOG_WARN 2 /*!< Error conditions from which recovery measures have been taken */ | ||
#define ASYNC_WS_LOG_INFO 3 /*!< Information messages which describe normal flow of events */ | ||
#define ASYNC_WS_LOG_DEBUG 4 /*!< Extra information which is not necessary for normal use (values, pointers, sizes, etc). */ | ||
#define ASYNC_WS_LOG_VERBOSE 5 /*!< Verbose information for debugging purposes */ | ||
#define ASYNC_WS_LOG_MAX 6 /*!< Number of levels supported */ | ||
// set default log level | ||
#ifndef ASYNCWEBSERVER_LOG_LEVEL | ||
#define ASYNCWEBSERVER_LOG_LEVEL ASYNC_WS_LOG_INFO | ||
#endif | ||
// error | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_ERROR | ||
#define async_ws_log_e(format, ...) Serial.printf("E async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_e(format, ...) | ||
#endif | ||
// warn | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_WARN | ||
#define async_ws_log_w(format, ...) Serial.printf("W async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_w(format, ...) | ||
#endif | ||
// info | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_INFO | ||
#define async_ws_log_i(format, ...) Serial.printf("I async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_i(format, ...) | ||
#endif | ||
// debug | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_DEBUG | ||
#define async_ws_log_d(format, ...) Serial.printf("D async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_d(format, ...) | ||
#endif | ||
// verbose | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_VERBOSE | ||
#define async_ws_log_v(format, ...) Serial.printf("V async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_v(format, ...) | ||
#endif | ||
|
||
/** | ||
* ESP8266 specific configurations | ||
*/ | ||
#elif defined(ESP8266) | ||
#include <ets_sys.h> | ||
// define log levels | ||
#define ASYNC_WS_LOG_NONE 0 /*!< No log output */ | ||
#define ASYNC_WS_LOG_ERROR 1 /*!< Critical errors, software module can not recover on its own */ | ||
#define ASYNC_WS_LOG_WARN 2 /*!< Error conditions from which recovery measures have been taken */ | ||
#define ASYNC_WS_LOG_INFO 3 /*!< Information messages which describe normal flow of events */ | ||
#define ASYNC_WS_LOG_DEBUG 4 /*!< Extra information which is not necessary for normal use (values, pointers, sizes, etc). */ | ||
#define ASYNC_WS_LOG_VERBOSE 5 /*!< Verbose information for debugging purposes */ | ||
#define ASYNC_WS_LOG_MAX 6 /*!< Number of levels supported */ | ||
// set default log level | ||
#ifndef ASYNCWEBSERVER_LOG_LEVEL | ||
#define ASYNCWEBSERVER_LOG_LEVEL ASYNC_WS_LOG_INFO | ||
#endif | ||
// error | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_ERROR | ||
#define async_ws_log_e(format, ...) ets_printf(String(F("E async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_e(format, ...) | ||
#endif | ||
// warn | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_WARN | ||
#define async_ws_log_w(format, ...) ets_printf(String(F("W async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_w(format, ...) | ||
#endif | ||
// info | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_INFO | ||
#define async_ws_log_i(format, ...) ets_printf(String(F("I async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_i(format, ...) | ||
#endif | ||
// debug | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_DEBUG | ||
#define async_ws_log_d(format, ...) ets_printf(String(F("D async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_d(format, ...) | ||
#endif | ||
// verbose | ||
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_VERBOSE | ||
#define async_ws_log_v(format, ...) ets_printf(String(F("V async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__); | ||
#else | ||
#define async_ws_log_v(format, ...) | ||
#endif | ||
|
||
/** | ||
* Arduino specific configurations | ||
*/ | ||
#elif defined(ARDUINO) | ||
#if defined(USE_ESP_IDF_LOG) | ||
#include <esp_log.h> | ||
#define async_ws_log_e(format, ...) ESP_LOGE("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#define async_ws_log_w(format, ...) ESP_LOGW("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#define async_ws_log_i(format, ...) ESP_LOGI("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#define async_ws_log_d(format, ...) ESP_LOGD("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#define async_ws_log_v(format, ...) ESP_LOGV("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
|
||
#else | ||
#include <esp32-hal-log.h> | ||
#define async_ws_log_e(format, ...) log_e(format, ##__VA_ARGS__) | ||
#define async_ws_log_w(format, ...) log_w(format, ##__VA_ARGS__) | ||
#define async_ws_log_i(format, ...) log_i(format, ##__VA_ARGS__) | ||
#define async_ws_log_d(format, ...) log_d(format, ##__VA_ARGS__) | ||
#define async_ws_log_v(format, ...) log_v(format, ##__VA_ARGS__) | ||
#endif // USE_ESP_IDF_LOG | ||
|
||
/** | ||
* ESP-IDF specific configurations | ||
*/ | ||
#else | ||
#include <esp_log.h> | ||
#define async_ws_log_e(format, ...) ESP_LOGE("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#define async_ws_log_w(format, ...) ESP_LOGW("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#define async_ws_log_i(format, ...) ESP_LOGI("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#define async_ws_log_d(format, ...) ESP_LOGD("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#define async_ws_log_v(format, ...) ESP_LOGV("async_ws", "%s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
#endif // !LIBRETINY && !ARDUINO | ||
|
||
#endif // ASYNCWEBSERVER_LOG_CUSTOM |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.