Skip to content

Adding Debug.info() style functions #29

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

Closed
MiheerLele opened this issue Aug 14, 2022 · 4 comments · Fixed by #31
Closed

Adding Debug.info() style functions #29

MiheerLele opened this issue Aug 14, 2022 · 4 comments · Fixed by #31
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@MiheerLele
Copy link

MiheerLele commented Aug 14, 2022

Hi, has there been any discussion around adding individual functions for each debug logging level, instead of passing in the level explicitly, similar to how the logging module in python works? I believe something like this should work:

void Arduino_DebugUtils::info(const char * fmt, ...)
{
  va_list args;
  va_start(args, fmt);
  print(DBG_INFO, fmt, args);
  va_end(args);
}

I would be more than happy to open a PR if this feels like something that should be added

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Aug 14, 2022
@aentinger
Copy link
Contributor

Hi @MiheerLele ☕ 👋

This is technically perfectly doable, but would it not add a lot of code duplication? Basically every function would contain the same code, except a different constant as first parameter of print 🤷 . What is the advantage of such an API over the existing one from your perspective?

Cheers, Alex

@MiheerLele
Copy link
Author

MiheerLele commented Aug 26, 2022

Hi Alex,

Agreed, I was just curious to see if you thought one less parameter would be a beneficial tradeoff for the additional API methods. Debug.info( ... ) felt more usable than Debug.print(DBG_INFO, ... )

@aentinger
Copy link
Contributor

🤷 It would be simpler. Another alternative would be to provide macros, as done here. What do you think? That's the biggest simplification imho.

@MiheerLele
Copy link
Author

I think thats a good solution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants