Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
17 const char *name;
19#ifdef CONFIG_NIOS2
20 /* Workaround alert! Dummy data to ensure that structure is >8 bytes.
21 * Nios2 uses global pointer register for structures <=8 bytes and
22 * apparently does not handle well variables placed in custom sections.
23 */
24 uint32_t dummy;
25#endif
26};
27
31#ifdef CONFIG_NIOS2
32 /* Workaround alert! Dummy data to ensure that structure is >8 bytes.
33 * Nios2 uses global pointer register for structures <=8 bytes and
34 * apparently does not handle well variables placed in custom sections.
35 */
36 uint32_t dummy[2];
37#endif
38#if defined(CONFIG_RISCV) && defined(CONFIG_64BIT)
39 /* Workaround: RV64 needs to ensure that structure is just 8 bytes. */
40 uint32_t dummy;
41#endif
42};
43
50#define Z_LOG_ITEM_CONST_DATA(_name) UTIL_CAT(log_const_, _name)
51
63#define Z_LOG_CONST_ITEM_REGISTER(_name, _str_name, _level) \
64 const struct log_source_const_data Z_LOG_ITEM_CONST_DATA(_name) \
65 __attribute__ ((section("." STRINGIFY(Z_LOG_ITEM_CONST_DATA(_name))))) \
66 __attribute__((used)) = { \
67 .name = _str_name, \
68 .level = (_level), \
69 }
70
79#define LOG_OBJECT_PTR_INIT(_name, _object) \
80 IF_ENABLED(CONFIG_LOG, (._name = _object,))
81
86#define Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst_name) \
87 UTIL_CAT(_module_name, UTIL_CAT(_, _inst_name))
88
98#define Z_LOG_OBJECT_PTR(_name) \
99 COND_CODE_1(CONFIG_LOG_RUNTIME_FILTERING, \
100 (&LOG_ITEM_DYNAMIC_DATA(_name)), \
101 (&Z_LOG_ITEM_CONST_DATA(_name))) \
102
112#define LOG_INSTANCE_PTR(_module_name, _inst_name) \
113 Z_LOG_OBJECT_PTR(Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst_name))
114
127#define LOG_INSTANCE_PTR_INIT(_name, _module_name, _inst_name) \
128 LOG_OBJECT_PTR_INIT(_name, LOG_INSTANCE_PTR(_module_name, _inst_name))
129
130#define Z_LOG_INSTANCE_STRUCT \
131 COND_CODE_1(CONFIG_LOG_RUNTIME_FILTERING, \
132 (struct log_source_dynamic_data), \
133 (const struct log_source_const_data))
134
141#define LOG_INSTANCE_PTR_DECLARE(_name) \
142 IF_ENABLED(CONFIG_LOG, (Z_LOG_INSTANCE_STRUCT * _name))
143
144#define Z_LOG_RUNTIME_INSTANCE_REGISTER(_module_name, _inst_name) \
145 struct log_source_dynamic_data LOG_INSTANCE_DYNAMIC_DATA(_module_name, _inst_name) \
146 __attribute__ ((section("." STRINGIFY( \
147 LOG_INSTANCE_DYNAMIC_DATA(_module_name, _inst_name) \
148 ) \
149 ))) __attribute__((used))
150
151#define Z_LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level) \
152 Z_LOG_CONST_ITEM_REGISTER( \
153 Z_LOG_INSTANCE_FULL_NAME(_module_name, _inst_name), \
154 STRINGIFY(_module_name._inst_name), \
155 _level); \
156 IF_ENABLED(CONFIG_LOG_RUNTIME_FILTERING, \
157 (Z_LOG_RUNTIME_INSTANCE_REGISTER(_module_name, _inst_name)))
158
170#define LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level) \
171 IF_ENABLED(CONFIG_LOG, (Z_LOG_INSTANCE_REGISTER(_module_name, _inst_name, _level)))
172
173#ifdef __cplusplus
174}
175#endif
176
177#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_INSTANCE_H_ */
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Constant data associated with the source of log messages.
Definition: log_instance.h:16
uint8_t level
Definition: log_instance.h:18
const char * name
Definition: log_instance.h:17
Dynamic data associated with the source of log messages.
Definition: log_instance.h:29
uint32_t filters
Definition: log_instance.h:30