-
Notifications
You must be signed in to change notification settings - Fork 7k
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
log: make name param explicit #9450
Conversation
@pizi-nordic any idea how to handle getting the name dynamically to fix / remove use of LOG_MODULE_NAME in LOG_CURRENT_MODULE_ID & LOG_CURRENT_DYNAMIC_DATA_ADDR |
Codecov Report
@@ Coverage Diff @@
## master #9450 +/- ##
==========================================
+ Coverage 52.31% 52.51% +0.19%
==========================================
Files 212 213 +1
Lines 25937 26082 +145
Branches 5589 5624 +35
==========================================
+ Hits 13569 13696 +127
- Misses 10122 10135 +13
- Partials 2246 2251 +5
Continue to review full report at Codecov.
|
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.
doc changes look OK
@galak: The logger does not need What about the following solution:
The compiler should optimize out these functions and you will get something local to current compilation unit. @nordic-krch: Could you please express your opinion on this proposal when you will be back in the office :) |
@galak, @pizi-nordic proposal looks good imo. |
@pizi-nordic do you want to go head and make the change you suggested? |
@galak, @pizi-nordic is on vacation. I've applied his suggestion by modifying last commit on my fork (https://github.com/nordic-krch/zephyr/commits/logging). Not sure how to proceed with that? |
Thanks, I pulled your changes into my tree and made a few updates. |
Is it possible to use logger after this commit with module_foo from a static inline routine in module_foo.h, as well as with module_bar from module_bar.c, where module_bar.c includes module_foo.h? I am guessing the previous way 'ought' to work, possibly with some warnings for redefining the macro, but I'm less sure about the effect this PR would have on that. @galak, can you clarify? |
I'm thinking of situations like this. What should the behavior be in general (with or without implicit names)? /******************************************************************************
* in module_foo.h:
*/
#define LOG_MODULE_NAME foo
#include <logging/log.h>
LOG_MODULE_REGISTER();
static inline void module_foo_func(void)
{
LOG_INF("hello from foo");
}
/******************************************************************************
* in module_bar.c:
*/
#include <module_foo.h>
#define LOG_MODULE_NAME bar
#include <logging/log.h>
LOG_MODULE_REGISTER();
void module_bar_func(void)
{
module_foo_func();
LOG_INF("hello from bar");
} |
@mbolivar it's not only after this commit but in general using log in head it risky. I haven't yet into that but probably we would need to preceed every #define LOG_MODULE_NAME with #undef LOG_MODULE_NAME and use LOG_MODULE_DECLARE() in header and LOG_MODULE_REGISTER in C file. |
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.
lgtm. Not sure why shippable complains about line length. It usually accepts my 'signed-off-by'.
edit: missing dash probably: Signed-off by: Krzysztof Chruscinski krzysztof.chruscinski@nordicsemi.no
Rather than having some implied name for the logging name, explicitly pass it in the macros LOG_MODULE_REGISTER & LOG_MODULE_DECLARE. Signed-off-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Is that type of approach compatible with the changes @galak is suggesting? Naively it doesn't seem so, since the idea is to delete LOG_MODULE_NAME usage. |
Yeah, we should assume magic #defines being set, thus me merging this. |
Rather than having some implied name for the logging name, explicitly
pass it in the macros LOG_MODULE_REGISTER & LOG_MODULE_DECLARE.
Signed-off-by: Kumar Gala kumar.gala@linaro.org