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

Replace LOG_ macros with logger abstraction. #31

Open
devYaoYH opened this issue Feb 4, 2025 · 1 comment
Open

Replace LOG_ macros with logger abstraction. #31

devYaoYH opened this issue Feb 4, 2025 · 1 comment
Assignees

Comments

@devYaoYH
Copy link
Contributor

devYaoYH commented Feb 4, 2025

Introduce a module src/logger to hide complexity of switching between TEST/RELEASE version of logging, also provides the interface to introduce functionality for FLASH/DISK logging behavior (when drivers are available).

One imagines a common interface like:

/* Single main logging function
 * Parameters:
 *  LOG_LEVEL: DEBUG/INFO/ERROR
 *  SINK_BITMASK: 0bxyz (x - FLASH, y - DISK, z - TEST)
 *  fmt: printf-like format string
 *  args: variable args
 */
void log(enum LOG_LEVEL, uint8 SINK_BITMASK, char* fmt, args...)

// Macros for convenience & backward compatibility with current code
// Notice the `| TEST` bitwise operator here to automatically enable TESTING mode based on
// define flag passed through from cmake build commands.
LOG_DEBUG(fmt, ...)                                                    \
    log(DEBUG, 0b010 | TEST, "[DEBUG]    " fmt "\n" __VA_OPT__(, ) __VA_ARGS__)
@Darrow8
Copy link
Contributor

Darrow8 commented Feb 15, 2025

I have created logger branch for this, work in progress right now.

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

No branches or pull requests

2 participants