1 /*
2  * Copyright (c) 2018 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef ZEPHYR_INCLUDE_LOGGING_LOG_CORE_H_
7 #define ZEPHYR_INCLUDE_LOGGING_LOG_CORE_H_
8 
9 #include <zephyr/logging/log_msg.h>
10 #include <zephyr/logging/log_instance.h>
11 #include <stdbool.h>
12 #include <stdint.h>
13 #include <stdarg.h>
14 #include <zephyr/sys/util.h>
15 
16 /* This header file keeps all macros and functions needed for creating logging
17  * messages (macros like @ref LOG_ERR).
18  */
19 #define LOG_LEVEL_NONE 0U
20 #define LOG_LEVEL_ERR  1U
21 #define LOG_LEVEL_WRN  2U
22 #define LOG_LEVEL_INF  3U
23 #define LOG_LEVEL_DBG  4U
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #ifndef CONFIG_LOG
30 #define CONFIG_LOG_DEFAULT_LEVEL 0U
31 #define CONFIG_LOG_MAX_LEVEL 0U
32 #endif
33 
34 /* Id of local domain. */
35 #define Z_LOG_LOCAL_DOMAIN_ID 0
36 
37 #define LOG_FUNCTION_PREFIX_MASK \
38 	(((uint32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_ERR) << \
39 	  LOG_LEVEL_ERR) | \
40 	 ((uint32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_WRN) << \
41 	  LOG_LEVEL_WRN) | \
42 	 ((uint32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_INF) << \
43 	  LOG_LEVEL_INF) | \
44 	 ((uint32_t)IS_ENABLED(CONFIG_LOG_FUNC_NAME_PREFIX_DBG) << LOG_LEVEL_DBG))
45 
46 /** @brief Macro for returning local level value if defined or default.
47  *
48  * Check @ref IS_ENABLED macro for detailed explanation of the trick.
49  */
50 #define Z_LOG_RESOLVED_LEVEL(_level, _default) \
51 	Z_LOG_RESOLVED_LEVEL1(_level, _default)
52 
53 #define Z_LOG_RESOLVED_LEVEL1(_level, _default) \
54 	__COND_CODE(_LOG_XXXX##_level, (_level), (_default))
55 
56 #define _LOG_XXXX0  _LOG_YYYY,
57 #define _LOG_XXXX0U _LOG_YYYY,
58 #define _LOG_XXXX1  _LOG_YYYY,
59 #define _LOG_XXXX1U _LOG_YYYY,
60 #define _LOG_XXXX2  _LOG_YYYY,
61 #define _LOG_XXXX2U _LOG_YYYY,
62 #define _LOG_XXXX3  _LOG_YYYY,
63 #define _LOG_XXXX3U _LOG_YYYY,
64 #define _LOG_XXXX4  _LOG_YYYY,
65 #define _LOG_XXXX4U _LOG_YYYY,
66 
67 /**
68  * @brief Macro for conditional code generation if provided log level allows.
69  *
70  * Macro behaves similarly to standard \#if \#else \#endif clause. The
71  * difference is that it is evaluated when used and not when header file is
72  * included.
73  *
74  * @param _eval_level Evaluated level. If level evaluates to one of existing log
75  *		      log level (1-4) then macro evaluates to _iftrue.
76  * @param _iftrue     Code that should be inserted when evaluated to true. Note,
77  *		      that parameter must be provided in brackets.
78  * @param _iffalse    Code that should be inserted when evaluated to false.
79  *		      Note, that parameter must be provided in brackets.
80  */
81 #define Z_LOG_EVAL(_eval_level, _iftrue, _iffalse) \
82 	Z_LOG_EVAL1(_eval_level, _iftrue, _iffalse)
83 
84 #define Z_LOG_EVAL1(_eval_level, _iftrue, _iffalse) \
85 	__COND_CODE(_LOG_ZZZZ##_eval_level, _iftrue, _iffalse)
86 
87 #define _LOG_ZZZZ1  _LOG_YYYY,
88 #define _LOG_ZZZZ1U _LOG_YYYY,
89 #define _LOG_ZZZZ2  _LOG_YYYY,
90 #define _LOG_ZZZZ2U _LOG_YYYY,
91 #define _LOG_ZZZZ3  _LOG_YYYY,
92 #define _LOG_ZZZZ3U _LOG_YYYY,
93 #define _LOG_ZZZZ4  _LOG_YYYY,
94 #define _LOG_ZZZZ4U _LOG_YYYY,
95 
96 /**
97  *
98  * @brief Macro for getting ID of current module.
99  */
100 #define LOG_CURRENT_MODULE_ID() (__log_level != 0 ? \
101 	log_const_source_id(__log_current_const_data) : 0U)
102 
103 /* Set of defines that are set to 1 if function name prefix is enabled for given level. */
104 #define Z_LOG_FUNC_PREFIX_0U 0
105 #define Z_LOG_FUNC_PREFIX_1U COND_CODE_1(CONFIG_LOG_FUNC_NAME_PREFIX_ERR, (1), (0))
106 #define Z_LOG_FUNC_PREFIX_2U COND_CODE_1(CONFIG_LOG_FUNC_NAME_PREFIX_WRN, (1), (0))
107 #define Z_LOG_FUNC_PREFIX_3U COND_CODE_1(CONFIG_LOG_FUNC_NAME_PREFIX_INF, (1), (0))
108 #define Z_LOG_FUNC_PREFIX_4U COND_CODE_1(CONFIG_LOG_FUNC_NAME_PREFIX_DBG, (1), (0))
109 
110 /**
111  * @brief Macro for optional injection of function name as first argument of
112  *	  formatted string. COND_CODE_0() macro is used to handle no arguments
113  *	  case.
114  *
115  * The purpose of this macro is to prefix string literal with format specifier
116  * for function name and inject function name as first argument. In order to
117  * handle string with no arguments _LOG_Z_EVAL is used.
118  */
119 #define Z_LOG_STR_WITH_PREFIX2(...) \
120 	"%s: " GET_ARG_N(1, __VA_ARGS__), (const char *)__func__\
121 		COND_CODE_0(NUM_VA_ARGS_LESS_1(__VA_ARGS__),\
122 			    (),\
123 			    (, GET_ARGS_LESS_N(1, __VA_ARGS__))\
124 			   )
125 
126 /* Macro handles case when no format string is provided: e.g. LOG_DBG().
127  * Handling of format string is deferred to the next level macro.
128  */
129 #define Z_LOG_STR_WITH_PREFIX(...) \
130 	COND_CODE_0(NUM_VA_ARGS_LESS_1(_, ##__VA_ARGS__), \
131 		("%s", (const char *)__func__), \
132 		(Z_LOG_STR_WITH_PREFIX2(__VA_ARGS__)))
133 
134 /**
135  * @brief Handle optional injection of function name as the first argument.
136  *
137  * Additionally, macro is handling the empty message case.
138  */
139 #define Z_LOG_STR(_level, ...) \
140 	COND_CODE_1(UTIL_CAT(Z_LOG_FUNC_PREFIX_##_level), \
141 		(Z_LOG_STR_WITH_PREFIX(__VA_ARGS__)), (__VA_ARGS__))
142 
143 #define Z_LOG_LEVEL_CHECK(_level, _check_level, _default_level) \
144 	((_level) <= Z_LOG_RESOLVED_LEVEL(_check_level, _default_level))
145 
146 #define Z_LOG_CONST_LEVEL_CHECK(_level)					    \
147 	(IS_ENABLED(CONFIG_LOG) &&					    \
148 	(Z_LOG_LEVEL_CHECK(_level, CONFIG_LOG_OVERRIDE_LEVEL, LOG_LEVEL_NONE) \
149 	||								    \
150 	((IS_ENABLED(CONFIG_LOG_OVERRIDE_LEVEL) == false) &&		    \
151 	((_level) <= __log_level) &&					    \
152 	((_level) <= CONFIG_LOG_MAX_LEVEL)				    \
153 	)								    \
154 	))
155 
156 /*****************************************************************************/
157 /****************** Definitions used by minimal logging *********************/
158 /*****************************************************************************/
159 void z_log_minimal_hexdump_print(int level, const void *data, size_t size);
160 void z_log_minimal_vprintk(const char *fmt, va_list ap);
161 void z_log_minimal_printk(const char *fmt, ...);
162 
163 #define Z_LOG_TO_PRINTK(_level, fmt, ...) do { \
164 	z_log_minimal_printk("%c: " fmt "\n", \
165 			     z_log_minimal_level_to_char(_level), \
166 			     ##__VA_ARGS__); \
167 } while (false)
168 
169 #define Z_LOG_TO_VPRINTK(_level, fmt, valist) do { \
170 	z_log_minimal_printk("%c: ", z_log_minimal_level_to_char(_level)); \
171 	z_log_minimal_vprintk(fmt, valist); \
172 	z_log_minimal_printk("\n"); \
173 } while (false)
174 
z_log_minimal_level_to_char(int level)175 static inline char z_log_minimal_level_to_char(int level)
176 {
177 	switch (level) {
178 	case LOG_LEVEL_ERR:
179 		return 'E';
180 	case LOG_LEVEL_WRN:
181 		return 'W';
182 	case LOG_LEVEL_INF:
183 		return 'I';
184 	case LOG_LEVEL_DBG:
185 		return 'D';
186 	default:
187 		return '?';
188 	}
189 }
190 
191 #define Z_LOG_INST(_inst) COND_CODE_1(CONFIG_LOG, (_inst), NULL)
192 
193 /* If strings are removed from the binary then there is a risk of creating invalid
194  * cbprintf package if %p is used with character pointer which is interpreted as
195  * string. A compile time check is performed (since format string is known at
196  * compile time) and check fails logging message is not created but error is
197  * emitted instead. String check may increase compilation time so it is not
198  * always performed (could significantly increase CI time).
199  */
200 #ifdef CONFIG_LOG_FMT_STRING_VALIDATE
201 #define LOG_STRING_WARNING(_mode, _src, ...) \
202 	    Z_LOG_MSG_CREATE(UTIL_NOT(IS_ENABLED(CONFIG_USERSPACE)), _mode, \
203 			     Z_LOG_LOCAL_DOMAIN_ID, _src, LOG_LEVEL_ERR, NULL, 0, \
204 			     "char pointer used for %%p, cast to void *:\"%s\"", \
205 			     GET_ARG_N(1, __VA_ARGS__))
206 
207 #define LOG_POINTERS_VALIDATE(string_ok, ...) \
208 	_Pragma("GCC diagnostic push") \
209 	_Pragma("GCC diagnostic ignored \"-Wpointer-arith\"") \
210 	string_ok = Z_CBPRINTF_POINTERS_VALIDATE(__VA_ARGS__); \
211 	_Pragma("GCC diagnostic pop")
212 #else
213 #define LOG_POINTERS_VALIDATE(string_ok, ...) string_ok = true
214 #define LOG_STRING_WARNING(_mode, _src, ...)
215 #endif
216 
217 /*****************************************************************************/
218 /****************** Macros for standard logging ******************************/
219 /*****************************************************************************/
220 /** @internal
221  * @brief Generic logging macro.
222  *
223  * It checks against static levels (resolved at compile timer), runtime levels
224  * and modes and dispatch to relevant processing path.
225  *
226  * @param _level Log message severity level.
227  *
228  * @param _inst Set to 1 for instance specific log message. 0 otherwise.
229  *
230  * @param _source Pointer to static source descriptor object. NULL when runtime filtering
231  * is enabled.
232  *
233  * @param _dsource Pointer to dynamic source descriptor. NULL when runtime filtering
234  * is disabled.
235  *
236  * @param ... String with arguments.
237  */
238 #define Z_LOG2(_level, _inst, _source, _dsource, ...) do { \
239 	if (!Z_LOG_CONST_LEVEL_CHECK(_level)) { \
240 		break; \
241 	} \
242 	if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL)) { \
243 		Z_LOG_TO_PRINTK(_level, __VA_ARGS__); \
244 		break; \
245 	} \
246 	/* For instance logging check instance specific static level */ \
247 	if (_inst != 0 && !IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) { \
248 		if (_level > ((struct log_source_const_data *)_source)->level) { \
249 			break; \
250 		} \
251 	} \
252 	\
253 	bool is_user_context = k_is_user_context(); \
254 	if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) && \
255 	    !is_user_context && _level > Z_LOG_RUNTIME_FILTER((_dsource)->filters)) { \
256 		break; \
257 	} \
258 	int _mode; \
259 	void *_src = IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) ? \
260 		(void *)(_dsource) : (void *)(_source); \
261 	bool string_ok; \
262 	LOG_POINTERS_VALIDATE(string_ok, __VA_ARGS__); \
263 	if (!string_ok) { \
264 		LOG_STRING_WARNING(_mode, _src, __VA_ARGS__); \
265 		break; \
266 	} \
267 	Z_LOG_MSG_CREATE(UTIL_NOT(IS_ENABLED(CONFIG_USERSPACE)), _mode, \
268 				  Z_LOG_LOCAL_DOMAIN_ID, _src, _level, NULL,\
269 			  0, __VA_ARGS__); \
270 	(void)_mode; \
271 	if (false) { \
272 		/* Arguments checker present but never evaluated.*/ \
273 		/* Placed here to ensure that __VA_ARGS__ are*/ \
274 		/* evaluated once when log is enabled.*/ \
275 		z_log_printf_arg_checker(__VA_ARGS__); \
276 	} \
277 } while (false)
278 
279 #define Z_LOG(_level, ...) \
280 	Z_LOG2(_level, 0, __log_current_const_data, __log_current_dynamic_data, __VA_ARGS__)
281 
282 #define Z_LOG_INSTANCE(_level, _inst, ...) do { \
283 	(void)_inst; \
284 	Z_LOG2(_level, 1, \
285 		COND_CODE_1(CONFIG_LOG_RUNTIME_FILTERING, (NULL), (Z_LOG_INST(_inst))), \
286 		(struct log_source_dynamic_data *)COND_CODE_1( \
287 						CONFIG_LOG_RUNTIME_FILTERING, \
288 						(Z_LOG_INST(_inst)), (NULL)), \
289 		__VA_ARGS__); \
290 } while (0)
291 
292 /*****************************************************************************/
293 /****************** Macros for hexdump logging *******************************/
294 /*****************************************************************************/
295 /** @internal
296  * @brief Generic logging macro.
297  *
298  * It checks against static levels (resolved at compile timer), runtime levels
299  * and modes and dispatch to relevant processing path.
300  *
301  * @param _level Log message severity level.
302  *
303  * @param _inst Set to 1 for instance specific log message. 0 otherwise.
304  *
305  * @param _source Pointer to static source descriptor object. NULL when runtime filtering
306  * is enabled.
307  *
308  * @param _dsource Pointer to dynamic source descriptor. NULL when runtime filtering
309  * is disabled.
310  *
311  * @param _data Hexdump data;
312  *
313  * @param _len Hexdump data length.
314  *
315  * @param ... String.
316  */
317 #define Z_LOG_HEXDUMP2(_level, _inst, _source, _dsource, _data, _len, ...) do { \
318 	const char *_str = GET_ARG_N(1, __VA_ARGS__); \
319 	if (!Z_LOG_CONST_LEVEL_CHECK(_level)) {	\
320 		break; \
321 	} \
322 	/* For instance logging check instance specific static level */ \
323 	if (_inst && !IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) { \
324 		if (_level > ((struct log_source_const_data *)_source)->level) { \
325 			break; \
326 		} \
327 	} \
328 	bool is_user_context = k_is_user_context(); \
329 	uint32_t filters = IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) ? \
330 						(_dsource)->filters : 0;\
331 	\
332 	if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL)) { \
333 		Z_LOG_TO_PRINTK(_level, "%s", _str); \
334 		z_log_minimal_hexdump_print((_level), \
335 					    (const char *)(_data), (_len));\
336 		break; \
337 	} \
338 	if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) && \
339 	    !is_user_context && (_level) > Z_LOG_RUNTIME_FILTER(filters)) { \
340 		break; \
341 	} \
342 	int mode; \
343 	void *_src = IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) ? \
344 		(void *)(_dsource) : (void *)(_source); \
345 	Z_LOG_MSG_CREATE(UTIL_NOT(IS_ENABLED(CONFIG_USERSPACE)), mode, \
346 				  Z_LOG_LOCAL_DOMAIN_ID, _src, _level, \
347 			  _data, _len, \
348 			COND_CODE_0(NUM_VA_ARGS_LESS_1(_, ##__VA_ARGS__), \
349 				(), \
350 			  (COND_CODE_0(NUM_VA_ARGS_LESS_1(__VA_ARGS__), \
351 				  ("%s", __VA_ARGS__), (__VA_ARGS__)))));\
352 } while (false)
353 
354 #define Z_LOG_HEXDUMP(_level, _data, _length, ...) \
355 	Z_LOG_HEXDUMP2(_level, 0, \
356 		      __log_current_const_data, \
357 		      __log_current_dynamic_data, \
358 		      _data, _length, __VA_ARGS__)
359 
360 #define Z_LOG_HEXDUMP_INSTANCE(_level, _inst, _data, _length, _str) \
361 	Z_LOG_HEXDUMP2(_level, 1, \
362 		COND_CODE_1(CONFIG_LOG_RUNTIME_FILTERING, (NULL), (Z_LOG_INST(_inst))), \
363 		(struct log_source_dynamic_data *)COND_CODE_1( \
364 						CONFIG_LOG_RUNTIME_FILTERING, \
365 						(Z_LOG_INST(_inst)), (NULL)), \
366 		_data, _length, _str)
367 
368 /*****************************************************************************/
369 /****************** Filtering macros *****************************************/
370 /*****************************************************************************/
371 
372 /** @brief Number of bits used to encode log level. */
373 #define LOG_LEVEL_BITS 3U
374 
375 /** @brief Filter slot size. */
376 #define LOG_FILTER_SLOT_SIZE LOG_LEVEL_BITS
377 
378 /** @brief Number of slots in one word. */
379 #define LOG_FILTERS_NUM_OF_SLOTS (32 / LOG_FILTER_SLOT_SIZE)
380 
381 /** @brief Maximum number of backends supported when runtime filtering is enabled. */
382 #define LOG_FILTERS_MAX_BACKENDS \
383 	(LOG_FILTERS_NUM_OF_SLOTS - (1 + IS_ENABLED(CONFIG_LOG_FRONTEND)))
384 
385 /** @brief Slot reserved for the frontend. Last slot is used. */
386 #define LOG_FRONTEND_SLOT_ID (LOG_FILTERS_NUM_OF_SLOTS - 1)
387 
388 /** @brief Slot mask. */
389 #define LOG_FILTER_SLOT_MASK (BIT(LOG_FILTER_SLOT_SIZE) - 1U)
390 
391 /** @brief Bit offset of a slot.
392  *
393  *  @param _id Slot ID.
394  */
395 #define LOG_FILTER_SLOT_SHIFT(_id) (LOG_FILTER_SLOT_SIZE * (_id))
396 
397 #define LOG_FILTER_SLOT_GET(_filters, _id) \
398 	((*(_filters) >> LOG_FILTER_SLOT_SHIFT(_id)) & LOG_FILTER_SLOT_MASK)
399 
400 #define LOG_FILTER_SLOT_SET(_filters, _id, _filter)		     \
401 	do {							     \
402 		*(_filters) &= ~(LOG_FILTER_SLOT_MASK <<	     \
403 				 LOG_FILTER_SLOT_SHIFT(_id));	     \
404 		*(_filters) |= ((_filter) & LOG_FILTER_SLOT_MASK) << \
405 			       LOG_FILTER_SLOT_SHIFT(_id);	     \
406 	} while (false)
407 
408 #define LOG_FILTER_AGGR_SLOT_IDX 0
409 
410 #define LOG_FILTER_AGGR_SLOT_GET(_filters) \
411 	LOG_FILTER_SLOT_GET(_filters, LOG_FILTER_AGGR_SLOT_IDX)
412 
413 #define LOG_FILTER_FIRST_BACKEND_SLOT_IDX 1
414 
415 /* Return aggregated (highest) level for all enabled backends, e.g. if there
416  * are 3 active backends, one backend is set to get INF logs from a module and
417  * two other backends are set for ERR, returned level is INF.
418  */
419 #define Z_LOG_RUNTIME_FILTER(_filter) \
420 	LOG_FILTER_SLOT_GET(&(_filter), LOG_FILTER_AGGR_SLOT_IDX)
421 
422 /** @brief Log level value used to indicate log entry that should not be
423  *	   formatted (raw string).
424  */
425 #define LOG_LEVEL_INTERNAL_RAW_STRING LOG_LEVEL_NONE
426 
427 TYPE_SECTION_START_EXTERN(struct log_source_const_data, log_const);
428 TYPE_SECTION_END_EXTERN(struct log_source_const_data, log_const);
429 
430 /** @brief Create message for logging printk-like string or a raw string.
431  *
432  * Part of printk string processing is appending of carriage return after any
433  * new line character found in the string. If it is not desirable then @p _is_raw
434  * can be set to 1 to indicate raw string. This information is stored in the source
435  * field which is not used for its typical purpose in this case.
436  *
437  * @param _is_raw	Set to 1 to indicate raw string, set to 0 to indicate printk.
438  * @param ...		Format string with arguments.
439  */
440 #define Z_LOG_PRINTK(_is_raw, ...) do { \
441 	if (!IS_ENABLED(CONFIG_LOG)) { \
442 		break; \
443 	} \
444 	if (IS_ENABLED(CONFIG_LOG_MODE_MINIMAL)) { \
445 		z_log_minimal_printk(__VA_ARGS__); \
446 		break; \
447 	} \
448 	int _mode; \
449 	if (0) {\
450 		z_log_printf_arg_checker(__VA_ARGS__); \
451 	} \
452 	Z_LOG_MSG_CREATE(!IS_ENABLED(CONFIG_USERSPACE), _mode, \
453 			  Z_LOG_LOCAL_DOMAIN_ID, (const void *)(uintptr_t)_is_raw, \
454 			  LOG_LEVEL_INTERNAL_RAW_STRING, NULL, 0, __VA_ARGS__);\
455 } while (0)
456 
457 /** @brief Get index of the log source based on the address of the constant data
458  *         associated with the source.
459  *
460  * @param data Address of the constant data.
461  *
462  * @return Source ID.
463  */
log_const_source_id(const struct log_source_const_data * data)464 static inline uint32_t log_const_source_id(
465 				const struct log_source_const_data *data)
466 {
467 	return ((const uint8_t *)data - (uint8_t *)TYPE_SECTION_START(log_const))/
468 			sizeof(struct log_source_const_data);
469 }
470 
471 TYPE_SECTION_START_EXTERN(struct log_source_dynamic_data, log_dynamic);
472 TYPE_SECTION_END_EXTERN(struct log_source_dynamic_data, log_dynamic);
473 
474 /** @brief Creates name of variable and section for runtime log data.
475  *
476  *  @param _name Name.
477  */
478 #define LOG_ITEM_DYNAMIC_DATA(_name) UTIL_CAT(log_dynamic_, _name)
479 
480 #define LOG_INSTANCE_DYNAMIC_DATA(_module_name, _inst) \
481 	LOG_ITEM_DYNAMIC_DATA(Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst))
482 
483 /** @brief Get index of the log source based on the address of the dynamic data
484  *         associated with the source.
485  *
486  * @param data Address of the dynamic data.
487  *
488  * @return Source ID.
489  */
log_dynamic_source_id(struct log_source_dynamic_data * data)490 static inline uint32_t log_dynamic_source_id(struct log_source_dynamic_data *data)
491 {
492 	return ((uint8_t *)data - (uint8_t *)TYPE_SECTION_START(log_dynamic))/
493 			sizeof(struct log_source_dynamic_data);
494 }
495 
496 /** @brief Dummy function to trigger log messages arguments type checking. */
497 static inline __printf_like(1, 2)
z_log_printf_arg_checker(const char * fmt,...)498 void z_log_printf_arg_checker(const char *fmt, ...)
499 {
500 	ARG_UNUSED(fmt);
501 }
502 
503 /**
504  * @brief Write a generic log message.
505  *
506  * @note This function is intended to be used when porting other log systems.
507  *
508  * @param level          Log level..
509  * @param fmt            String to format.
510  * @param ap             Pointer to arguments list.
511  */
log_generic(uint8_t level,const char * fmt,va_list ap)512 static inline void log_generic(uint8_t level, const char *fmt, va_list ap)
513 {
514 	z_log_msg_runtime_vcreate(Z_LOG_LOCAL_DOMAIN_ID, NULL, level,
515 				   NULL, 0, 0, fmt, ap);
516 }
517 
518 #ifdef __cplusplus
519 }
520 #endif
521 
522 #endif /* ZEPHYR_INCLUDE_LOGGING_LOG_CORE_H_ */
523