Namespace Log Level Defines
I'm using Arduino Log in a project with other libraries that already have defines set up for LOG_LEVEL_ERROR amongst other things. This causes a number of warnings at compile time (and some strange behavior in the logs).
This PR renames the #defines to prepend ARDUINO_LOG_ thereby effectively namespacing them.
This renaming game is kind of open ended if we assume that each library is compatible with all other libraries at all time. Whilst I agree that the currently chosen name is quite wide, this change is also backwards incompatible. Is there a better way to rename these during a preprocessing phase in your project potentially? Or can we change the pull request so you can specify a prefix for these and leave it empty by default to ensure backwards compatibility?
Can you specify a prefix for preprocessor items?
I am not sure :)
On Wed, 12 Jan 2022, 09:49 John, @.***> wrote:
Can you specify a prefix for preprocessor items?
— Reply to this email directly, view it on GitHub https://github.com/thijse/Arduino-Log/pull/23#issuecomment-1010437159, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABN5BQ6DSFKQ655HELPH33UVSXY7ANCNFSM5LWT5ENA . You are receiving this because you commented.Message ID: @.***>
Same for CR LF etc. They are far too generic.
I quite agree that polluting the main namespace is annoying, but ARDUINO_LOG_LOG_LEVEL_SILENT and such are long, cumbersome and redundant?
ARDUINO_LOG_SILENT etc would be fine, OR just change them to be constexpr definitions instead of macros so they can go into a C++ namespace, which can then be pulled into the global namespace by default, but if you define -DARDUINO_LOG_NAMESPACE or something like that it will avoid doing so, thus allowing backward compatibility by default but new code can be more specific.
(Even then, arduino_log::Log.notice(...) would be a lot. Better would be something like alog::notice(...)?)