Refactor log level constants to enum class and improve macro compatibility#11
Open
Abasz wants to merge 5 commits intoJSC-TechMinds:mainfrom
Open
Refactor log level constants to enum class and improve macro compatibility#11Abasz wants to merge 5 commits intoJSC-TechMinds:mainfrom
enum class and improve macro compatibility#11Abasz wants to merge 5 commits intoJSC-TechMinds:mainfrom
Conversation
Fix the `printTimestamp` and `printCarret` call signature to match `printfunction` typedef.
Move writeLog definition into the header file. Fixes JSC-TechMinds#9. (JSC-TechMinds#9)
Add `ArduinoLogLevel` enum to replace int log levels. Update code to use the new enum type for log levels as well as add backward compatibility for existing int-based log level usage. This change improves type safety and readability of the code and most importantly fixes naming collision with nimble log levels.
Add undefine for old log level macros to avoid conflicts with other libraries (e.g. NimBLE) while keeping backward compatibility This ensures that the ArduinoLog library can be used without issues related to naming collisions. However, this may not 100% safe as include order will matter and that potentially can break other code that uses these macros and included after ArduinoLog.h.
When including ArduinoLog save any existing definitions of LOG_LEVEL_* macros (e.g. from NimBLE) so that they can be restored after ArduinoLog is included to avoid compilation errors. This allows this library to coexist with others while keeping backward compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces several improvements and modernizations to the Arduino-Log library as suggested by #8:
1. Log Level as
enum classenum class ArduinoLogLevel.2. Backward Compatibility
LOG_LEVEL_ERROR, etc.) are still available for existing code (inconstexpralias).intlog level arguments are retained for legacy support, with safe conversion to the new enum (using the highest/lowest log level if passed int is out of bounds).3. Macro Conflict Handling
LOG_LEVEL_*macro definitions before undefining them.Potential Impact
Notes