Skip to content
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

More flexible logging functionality #53

Open
LnnrtS opened this issue Oct 2, 2020 · 1 comment
Open

More flexible logging functionality #53

LnnrtS opened this issue Oct 2, 2020 · 1 comment

Comments

@LnnrtS
Copy link
Contributor

LnnrtS commented Oct 2, 2020

If you asked me about the improvement to µOS++ that I would wish an update for, I'd say its the logging.

I have turned logging off completely because my applications already uses the ITM trace and I couldn't make both coexist in a reasonable manner. I see two problems with the current implementation

Log messages are too condensed

I guess this is due to performance reasons. I don't know what big of an influence the message length has vs the impact of calling into printf formatting at all. But as a developer I would kind of expect performance to decrease when having logging enabled so adding a bit of verbosity shouldn't hurt too much.

There are too little options to filter in which context a specific message should be printed or not

Right now there is only the option to enable/disable all logging for a specific type of object at compile time. In my experience this is not enough for targeted debugging. What would be great is:

  • Add a level to every message (for example Error, Warning, Info, Debug, Verbose)
  • Compile-time filtering by level to be omitted from the build completely
  • Changing the active level at run-time (with RAII helpers that restore the previous level when they go out of scope)
  • Global and per-thread level (I implemented that by extending os_thread_user_storage_t)
  • Ensure consistency of log messages (I protected the formatting and sending of every message by a robust mutex but that's probably not an ideal solution)
  • Use fmt for formatting (I have not used it myself but it has been added to the standard in c++20 although neither gcc not llvm seem to have integrated it yet)

I think the zephyr logging module is also worth looking at.

Would be interested in hearing your thoughts about that..

@ilg-ul
Copy link
Contributor

ilg-ul commented Oct 2, 2020

Log messages are too condensed - I guess this is due to performance reasons

That's correct, in some places time is critical and I tried to impact performances as little as possible. But I think that this can be changed, with a configuration variable we can emit longer messages.

Error, Warning, Info, Debug, Verbose

Yes, I considered this, but had no time to implement it yet. Hopefully in the next iteration. I have no experience with Zephyr, but if you think it is worth looking at, we'll consider it.

Use fmt for formatting

Yes, that's an idea worth considering. And I guess there might be more C++20 nice features to consider.

Actually I planned a rework of the newlib stdio functions, aiming for a better integration with the C++ functions. The idea was to have some core formatting functions, to be used both in C and C++, and some years ago I did some experiments, but I had no time to review them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants