Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
log_instance.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_INSTANCE_H_
7#define ZEPHYR_INCLUDE_LOGGING_LOG_INSTANCE_H_
8
9#include <zephyr/types.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
18 const char *name;
20#ifdef CONFIG_NIOS2
21 /* Workaround alert! Dummy data to ensure that structure is >8 bytes.
22 * Nios2 uses global pointer register for structures <=8 bytes and
23 * apparently does not handle well variables placed in custom sections.
24 */
25 uint32_t dummy;
26#endif
27};
28
32#ifdef CONFIG_NIOS2
33 /* Workaround alert! Dummy data to ensure that structure is >8 bytes.
34 * Nios2 uses global pointer register for structures <=8 bytes and
35 * apparently does not handle well variables placed in custom sections.
36 */
37 uint32_t dummy[2];
38#endif
39#if defined(CONFIG_64BIT)
40 /* Workaround: Ensure that structure size is a multiple of 8 bytes. */
41 uint32_t dummy_64;
42#endif
43};
44
51#define Z_LOG_ITEM_CONST_DATA(_name) UTIL_CAT(log_const_, _name)
52
64#define Z_LOG_CONST_ITEM_REGISTER(_name, _str_name, _level) \
65 const STRUCT_SECTION_ITERABLE_ALTERNATE(log_const, \
66 log_source_const_data, \
67 Z_LOG_ITEM_CONST_DATA(_name)) = \
68 { \
69 .name = _str_name, \
70 .level = (_level), \
71 }
72
81#define LOG_OBJECT_PTR_INIT(_name, _object) \
82 IF_ENABLED(CONFIG_LOG, (._name = _object,))
83
88#define Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst_name) \
89 UTIL_CAT(_module_name, UTIL_CAT(_, _inst_name))
90
100#define Z_LOG_OBJECT_PTR(_name) \
101 COND_CODE_1(CONFIG_LOG_RUNTIME_FILTERING, \
102 (&LOG_ITEM_DYNAMIC_DATA(_name)), \
103 (&Z_LOG_ITEM_CONST_DATA(_name))) \
104
114#define LOG_INSTANCE_PTR(_module_name, _inst_name) \
115 Z_LOG_OBJECT_PTR(Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst_name))
116
129#define LOG_INSTANCE_PTR_INIT(_name, _module_name, _inst_name) \
130 LOG_OBJECT_PTR_INIT(_name, LOG_INSTANCE_PTR(_module_name, _inst_name))
131
132#define Z_LOG_INSTANCE_STRUCT \
133 COND_CODE_1(CONFIG_LOG_RUNTIME_FILTERING, \
134 (struct log_source_dynamic_data), \
135 (const struct log_source_const_data))
136
147#define LOG_INSTANCE_PTR_DECLARE(_name) \
148 COND_CODE_1(CONFIG_LOG, (Z_LOG_INSTANCE_STRUCT * _name), \
149 (int _name[TOOLCHAIN_HAS_ZLA ? 0 : 1]))
150
151#define Z_LOG_RUNTIME_INSTANCE_REGISTER(_module_name, _inst_name) \
152 STRUCT_SECTION_ITERABLE_ALTERNATE(log_dynamic, log_source_dynamic_data, \
153 LOG_INSTANCE_DYNAMIC_DATA(_module_name, _inst_name))
154
155#define Z_LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level) \
156 Z_LOG_CONST_ITEM_REGISTER( \
157 Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst_name), \
158 STRINGIFY(_module_name._inst_name), \
159 _level); \
160 IF_ENABLED(CONFIG_LOG_RUNTIME_FILTERING, \
161 (Z_LOG_RUNTIME_INSTANCE_REGISTER(_module_name, _inst_name)))
162
174#define LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level) \
175 IF_ENABLED(CONFIG_LOG, (Z_LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level)))
176
177#ifdef __cplusplus
178}
179#endif
180
181#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_INSTANCE_H_ */
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Constant data associated with the source of log messages.
Definition log_instance.h:17
uint8_t level
Definition log_instance.h:19
const char * name
Definition log_instance.h:18
Dynamic data associated with the source of log messages.
Definition log_instance.h:30
uint32_t filters
Definition log_instance.h:31