diff --git a/doc/subsystems/logging/logger.rst b/doc/subsystems/logging/logger.rst index 19f7b94c816b9a..e4a1afb78a2170 100644 --- a/doc/subsystems/logging/logger.rst +++ b/doc/subsystems/logging/logger.rst @@ -145,10 +145,9 @@ module can be specified as well. .. code-block:: c - #define LOG_MODULE_NAME foo #define LOG_LEVEL CONFIG_FOO_LOG_LEVEL /* From foo module Kconfig */ #include - LOG_MODULE_REGISTER(); /* One per given LOG_MODULE_NAME */ + LOG_MODULE_REGISTER(foo); /* One per given log_module_name */ If the module consists of multiple files, then ``LOG_MODULE_REGISTER()`` should appear in exactly one of them. Each other file should use @@ -156,10 +155,9 @@ appear in exactly one of them. Each other file should use .. code-block:: c - #define LOG_MODULE_NAME foo #define LOG_LEVEL CONFIG_FOO_LOG_LEVEL /* From foo module Kconfig */ #include - LOG_MODULE_DECLARE(); /* In all files comprising the module but one */ + LOG_MODULE_DECLARE(foo); /* In all files comprising the module but one */ Logging in a module instance ============================ diff --git a/include/logging/log.h b/include/logging/log.h index 96bb1ef65a0159..e3e9f000829f3b 100644 --- a/include/logging/log.h +++ b/include/logging/log.h @@ -298,10 +298,10 @@ int log_printk(const char *fmt, va_list ap); * In other cases, this macro has no effect. * @see LOG_MODULE_DECLARE */ -#define LOG_MODULE_REGISTER() \ +#define LOG_MODULE_REGISTER(log_module_name) \ _LOG_EVAL( \ _LOG_LEVEL(), \ - (_LOG_MODULE_REGISTER(LOG_MODULE_NAME, _LOG_LEVEL())), \ + (_LOG_MODULE_REGISTER(log_module_name, _LOG_LEVEL())), \ ()/*Empty*/ \ ) @@ -336,10 +336,10 @@ int log_printk(const char *fmt, va_list ap); * this macro has no effect. * @see LOG_MODULE_REGISTER */ -#define LOG_MODULE_DECLARE() \ +#define LOG_MODULE_DECLARE(log_module_name) \ _LOG_EVAL( \ _LOG_LEVEL(), \ - (_LOG_MODULE_DECLARE(LOG_MODULE_NAME, _LOG_LEVEL())), \ + (_LOG_MODULE_DECLARE(log_module_name, _LOG_LEVEL())), \ () \ ) \ diff --git a/samples/subsys/logging/logger/src/ext_log_system_adapter.c b/samples/subsys/logging/logger/src/ext_log_system_adapter.c index 510d7e43531bf2..946508a1d5b9bd 100644 --- a/samples/subsys/logging/logger/src/ext_log_system_adapter.c +++ b/samples/subsys/logging/logger/src/ext_log_system_adapter.c @@ -9,7 +9,8 @@ #define LOG_MODULE_NAME ext_log_system #include -LOG_MODULE_REGISTER(); + +LOG_MODULE_REGISTER(ext_log_system); /** @brief Translation of custom log levels to logging subsystem levels. */ static const u8_t log_level_lut[] = { diff --git a/samples/subsys/logging/logger/src/main.c b/samples/subsys/logging/logger/src/main.c index c494d84774c75c..b62bfd2fb20825 100644 --- a/samples/subsys/logging/logger/src/main.c +++ b/samples/subsys/logging/logger/src/main.c @@ -14,9 +14,9 @@ #include "ext_log_system.h" #include "ext_log_system_adapter.h" -#define LOG_MODULE_NAME main #include -LOG_MODULE_REGISTER(); + +LOG_MODULE_REGISTER(main); /* size of stack area used by each thread */ #define STACKSIZE 1024 diff --git a/samples/subsys/logging/logger/src/sample_module.c b/samples/subsys/logging/logger/src/sample_module.c index f0a06cc330fdc2..a8f8c606efbd3f 100644 --- a/samples/subsys/logging/logger/src/sample_module.c +++ b/samples/subsys/logging/logger/src/sample_module.c @@ -7,7 +7,8 @@ #define LOG_MODULE_NAME foo #include -LOG_MODULE_REGISTER(); + +LOG_MODULE_REGISTER(LOG_MODULE_NAME); const char *sample_module_name_get(void) { diff --git a/tests/subsys/logging/log_core/src/log_core_test.c b/tests/subsys/logging/log_core/src/log_core_test.c index 5455c902e67802..bcd111774018ff 100644 --- a/tests/subsys/logging/log_core/src/log_core_test.c +++ b/tests/subsys/logging/log_core/src/log_core_test.c @@ -20,7 +20,8 @@ #define LOG_MODULE_NAME test #include "logging/log.h" -LOG_MODULE_REGISTER(); + +LOG_MODULE_REGISTER(LOG_MODULE_NAME); struct backend_cb { size_t counter;