Skip to content

Commit 262cc55

Browse files
nordic-krchnashif
authored andcommitted
logging: Deprecate v1, default to v2
Reduced logging mode selection to deferred, immediate, minimal and frontend. Decoupled logging version from mode and created CONFIG_LOG1 which can be used to explicitly select deprecated version. From now on, chosing CONFIG_LOG_MODE_{IMMEDIATE,DEFERRED} will result in version2. Deprecated CONFIG_LOG2_MODE_{IMMEDIATE,DEFERRED} with cmake warning. Codebase adapted to those changes. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
1 parent dd4035c commit 262cc55

File tree

47 files changed

+199
-178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+199
-178
lines changed

‎boards/posix/native_posix/doc/index.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ development by integrating more seamlessly with the host operating system:
644644
``--force-color``.
645645

646646
In native_posix, by default, the logger is configured with
647-
:kconfig:`CONFIG_LOG_IMMEDIATE`.
647+
:kconfig:`CONFIG_LOG_MODE_IMMEDIATE`.
648648

649649
This backend can be selected with :kconfig:`CONFIG_LOG_BACKEND_NATIVE_POSIX`
650650
and is enabled by default unless the native_posix UART is compiled in.

‎doc/reference/logging/index.rst‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,12 @@ Mode of operations:
117117

118118
:kconfig:`CONFIG_LOG_MODE_DEFERRED`: Deferred mode.
119119

120-
:kconfig:`CONFIG_LOG2_MODE_DEFERRED`: Deferred mode v2.
121-
122120
:kconfig:`CONFIG_LOG_MODE_IMMEDIATE`: Immediate (synchronous) mode.
123121

124-
:kconfig:`CONFIG_LOG2_MODE_IMMEDIATE`: Immediate (synchronous) mode v2.
125-
126122
:kconfig:`CONFIG_LOG_MODE_MINIMAL`: Minimal footprint mode.
127123

124+
:kconfig:`CONFIG_LOG1`: Use deprecated version of logging.
125+
128126
Filtering options:
129127

130128
:kconfig:`CONFIG_LOG_RUNTIME_FILTERING`: Enables runtime reconfiguration of the

‎include/logging/log_backend_std.h‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ log_backend_std_sync_string(const struct log_output *const output,
101101
flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
102102
}
103103

104-
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) &&
105-
IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
104+
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
106105
/* In order to ensure that one log processing is not interrupted
107106
* by another one, lock context for whole log processing.
108107
*/
@@ -111,8 +110,7 @@ log_backend_std_sync_string(const struct log_output *const output,
111110

112111
log_output_string(output, src_level, timestamp, fmt, ap, flags);
113112

114-
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) &&
115-
IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
113+
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
116114
irq_unlock(key);
117115
}
118116
}
@@ -144,8 +142,7 @@ log_backend_std_sync_hexdump(const struct log_output *const output,
144142
flags |= LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP;
145143
}
146144

147-
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) &&
148-
IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
145+
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
149146
/* In order to ensure that one log processing is not interrupted
150147
* by another one, lock context for whole log processing.
151148
*/
@@ -155,8 +152,7 @@ log_backend_std_sync_hexdump(const struct log_output *const output,
155152
log_output_hexdump(output, src_level, timestamp,
156153
metadata, data, length, flags);
157154

158-
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) &&
159-
IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
155+
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT)) {
160156
irq_unlock(key);
161157
}
162158
}

‎include/logging/log_core.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ extern "C" {
202202
#define Z_LOG_INTERNAL2(is_user_context, _src_level, ...) do { \
203203
if (is_user_context) { \
204204
log_from_user(_src_level, __VA_ARGS__); \
205-
} else if (IS_ENABLED(CONFIG_LOG_IMMEDIATE)) { \
205+
} else if (IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE)) { \
206206
log_string_sync(_src_level, __VA_ARGS__); \
207207
} else { \
208208
Z_LOG_INTERNAL_X(Z_LOG_NARGS_POSTFIX(__VA_ARGS__), \
@@ -442,7 +442,7 @@ static inline char z_log_minimal_level_to_char(int level)
442442
if (is_user_context) { \
443443
log_hexdump_from_user(src_level, _str, \
444444
(const char *)_data, _len); \
445-
} else if (IS_ENABLED(CONFIG_LOG_IMMEDIATE)) { \
445+
} else if (IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE)) { \
446446
log_hexdump_sync(src_level, _str, (const char *)_data, _len); \
447447
} else { \
448448
log_hexdump(_str, (const char *)_data, _len, src_level); \
@@ -860,7 +860,7 @@ static inline log_arg_t z_log_do_strdup(uint32_t msk, uint32_t idx,
860860
do { \
861861
if (is_user_context) { \
862862
log_generic_from_user(_src_level, _str, _valist); \
863-
} else if (IS_ENABLED(CONFIG_LOG_IMMEDIATE)) { \
863+
} else if (IS_ENABLED(CONFIG_LOG_MODE_IMMEDIATE)) { \
864864
log_generic(_src_level, _str, _valist, _strdup_action); \
865865
} else if (_argnum == 0) { \
866866
_LOG_INTERNAL_0(_src_level, _str); \

‎include/logging/log_ctrl.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,9 @@ uint32_t log_get_strdup_longest_string(void);
201201
*/
202202
static inline bool log_data_pending(void)
203203
{
204-
if (IS_ENABLED(CONFIG_LOG2_MODE_DEFERRED)) {
205-
return z_log_msg2_pending();
206-
} else if (IS_ENABLED(CONFIG_LOG_MODE_DEFERRED)) {
207-
return log_msg_mem_get_used() > 0;
204+
if (IS_ENABLED(CONFIG_LOG_MODE_DEFERRED)) {
205+
return IS_ENABLED(CONFIG_LOG2) ?
206+
z_log_msg2_pending() : (log_msg_mem_get_used() > 0);
208207
}
209208

210209
return false;

‎include/logging/log_msg2.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ do {\
353353
Z_LOG_FMT_ARGS(_fmt, ##__VA_ARGS__));\
354354
_mode = Z_LOG_MSG2_MODE_RUNTIME; \
355355
} while (0)
356-
#elif defined(CONFIG_LOG2_MODE_IMMEDIATE) /* CONFIG_LOG2_ALWAYS_RUNTIME */
356+
#elif defined(CONFIG_LOG_MODE_IMMEDIATE) /* CONFIG_LOG2_ALWAYS_RUNTIME */
357357
#define Z_LOG_MSG2_CREATE2(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
358358
_level, _data, _dlen, ...) \
359359
do { \

‎include/shell/shell_log_backend.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ int z_shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx);
9191
.log_output = &_name##_log_output, \
9292
.control_block = &_name##_control_block, \
9393
.timeout = _timeout, \
94-
.mpsc_buffer_config = IS_ENABLED(CONFIG_LOG2_MODE_DEFERRED) ? \
94+
.mpsc_buffer_config = IS_ENABLED(CONFIG_LOG2_DEFERRED) ? \
9595
&_name##_mpsc_buffer_config : NULL, \
96-
.mpsc_buffer = IS_ENABLED(CONFIG_LOG2_MODE_DEFERRED) ? \
96+
.mpsc_buffer = IS_ENABLED(CONFIG_LOG2_DEFERRED) ? \
9797
&_name##_mpsc_buffer : NULL, \
9898
}
9999

‎samples/bluetooth/iso_broadcast_benchmark/prj.conf‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ CONFIG_MAIN_STACK_SIZE=2048
1414

1515
CONFIG_LOG=y
1616
CONFIG_CBPRINTF_FP_SUPPORT=y
17-
CONFIG_LOG2_MODE_DEFERRED=y
1817
CONFIG_LOG_BUFFER_SIZE=2048

‎samples/bluetooth/iso_connected_benchmark/prj.conf‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ CONFIG_MAIN_STACK_SIZE=2048
1313

1414
CONFIG_LOG=y
1515
CONFIG_CBPRINTF_FP_SUPPORT=y
16-
CONFIG_LOG2_MODE_DEFERRED=y
1716
CONFIG_LOG_BUFFER_SIZE=2048

‎samples/subsys/logging/dictionary/prj.conf‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ CONFIG_LOG=y
22
CONFIG_LOG_PRINTK=y
33
CONFIG_LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX=y
44
CONFIG_LOG_BACKEND_UART=y
5-
CONFIG_LOG2_MODE_DEFERRED=y

0 commit comments

Comments
 (0)