Arduino-Log icon indicating copy to clipboard operation
Arduino-Log copied to clipboard

Namespace Log Level Defines

Open thorrak opened this issue 3 years ago • 5 comments

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.

thorrak avatar Jan 11 '22 15:01 thorrak

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?

joscha avatar Jan 11 '22 21:01 joscha

Can you specify a prefix for preprocessor items?

thorrak avatar Jan 11 '22 22:01 thorrak

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: @.***>

joscha avatar Jan 11 '22 23:01 joscha

Same for CR LF etc. They are far too generic.

mattbaker-digital avatar Feb 21 '24 12:02 mattbaker-digital

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(...)?)

egnor avatar Apr 16 '24 02:04 egnor