-
Notifications
You must be signed in to change notification settings - Fork 28
Logging refactoring to supports macros redefinition and -D USE_ESP_IDF_LOG #88
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
Conversation
5773602
to
de0ad6d
Compare
de0ad6d
to
e7a4420
Compare
0af8195
to
b505568
Compare
5aef991
to
3d840c8
Compare
60edfda
to
690fbe8
Compare
4d25cf9
to
56b57c2
Compare
9c6e0b1
to
f58768d
Compare
723eba7
to
d0eb53f
Compare
d0eb53f
to
26d46e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a design standpoint, I'd caution against replicating all the different log levels provided by ESP-IDF. I don't think the logging requirements of this particular library need that much depth; and carrying around a bunch of unused functions is asking for bit-rot unless there's some testing or validation suite, which seems like overkill in this case.
Instead I'd suggest providing log functions that fit the use cases in this library:
- error tracing (usally
log_e
, the onelog_w
could be included here, and probably a couple of thelog_d
s should probably be moved here) - full tracing (usually
// ets_printf()
currently); I think it would be better to make these properly supported logs than leave commented out lines - miscellaneous internal debugging (usually
log_d
)
..and then switch on some #define ASYNC_TCP_LOG (ASYNC_TCP_LOG_ERROR | ASYNC_TCP_LOG_TRACE | ASYNC_TCP_LOG_DEBUG)
to enable the required outputs.
So maybe we want only:
async_tcp_log_error
- enabled if (ASYNC_TCP_LOG & ASYNC_TCP_LOG_ERROR)
async_tcp_log_trace
- enabled if (ASYNC_TCP_LOG & ASYNC_TCP_LOG_TRACE )
async_tcp_log_debug
- enabled if (ASYNC_TCP_LOG & ASYNC_TCP_LOG_DEBUG)
?
26d46e3
to
c5cd35b
Compare
/** | ||
* ESP-IDF specific configurations | ||
*/ | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can AsyncTCP compile without Arduino?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it can now. there has been a recent PR and even an example in the project that you have reviewed. The dependency to Arduino is now gone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I still see that:
espressif/arduino-esp32:
version: ">=3.2.0"
require: public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@me-no-dev : found the PR: #48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this pr's title is misleading and should be - without arduino BUT with arduino as component maybe ?
We need also to support
In any case there is nothing more or less than we had except the some mapping macros, which would be empty anyway depending on the compilation flags also warning is good to have. if we do not support it now it can break backward compatibility when will need to use it.
|
c5cd35b
to
1710e36
Compare
9361058
to
f177ccf
Compare
f177ccf
to
e69ff60
Compare
Right, I understand that you've done the minimal possible port of the logs in the current code. I appreciate that you've added Elsewhere on the API design front: the only other thing that comes to mind is maybe to spec an |
|
Alas, in C++ we have to deal with static construction order indeterminacy -- someone might declare an (To be fair, I haven't tested if static It seemed to me like an init hook would be useful as way to allow custom log solutions to be more self contained, without potentially having to replicate the init check on every log call, or add explicit integration somewhere else in the user's code (ie. include this header, get more logs -- as opposed to include this header, and also add this call to your |
But in this case, why call it from _start_async_task ? _start_async_task can only be called from connect or begin and those 2 are more likely to not be called during static initialization because anyway there won't be any network layer ready to begin with (eth or wifi). I would understand if we had to call init from this static method if _start_async_task was called from a constructor, which would be likely to be statically called, yes, but I do not understand in which use case we would need this trick in AsyncTCP at the moment ? Especially that _start_async_task is called from begin or connect... So this is far away... There could be some log lines called (from ctor or from some validation methods) even before _start_async_task is called, so even before the init hook is called. |
This PR refactors the logging layer of async_tcp to give more flexibility.
By default, the lib internally uses these variants for logging:
Each call is by forwarded to the framework under the hood: log_x for Arduino and Libretiny, ESP_LOGx for ESP-IDF, or when using Arduino with
-D USE_ESP_IDF_LOG
If the flag
-D CONFIG_ASYNC_TCP_DEBUG
is set, the library switches in DEBUG mode and all the logs, regardless of their level, are sent to Serial output.If the flag
-D CONFIG_ASYNC_TCP_LOG_CUSTOM
is set, the user can provide in his projectAsyncTCPLoggingCustom.h
header and has the ability to then define the macros / function like he wants.The library will now support
-D USE_ESP_IDF_LOG
and has its own tag:async_tcp
, to useesp_log_level_set("async_tcp", ESP_LOG_INFO);