Line data Source code
1 0 : /*
2 : * Copyright (c) 2018 Nordic Semiconductor ASA
3 : * Copyright (c) 2021 Intel Corporation
4 : *
5 : * SPDX-License-Identifier: Apache-2.0
6 : */
7 : #ifndef ZEPHYR_INCLUDE_LOGGING_LOG_OUTPUT_DICT_H_
8 : #define ZEPHYR_INCLUDE_LOGGING_LOG_OUTPUT_DICT_H_
9 :
10 : #include <zephyr/logging/log_output.h>
11 : #include <zephyr/logging/log_msg.h>
12 : #include <stdarg.h>
13 : #include <zephyr/toolchain.h>
14 : #include <zephyr/sys/util.h>
15 :
16 : #ifdef __cplusplus
17 : extern "C" {
18 : #endif
19 :
20 : /**
21 : * Log message type
22 : */
23 0 : enum log_dict_output_msg_type {
24 : MSG_NORMAL = 0,
25 : MSG_DROPPED_MSG = 1,
26 : };
27 :
28 : /**
29 : * Output header for one dictionary based log message.
30 : */
31 1 : struct log_dict_output_normal_msg_hdr_t {
32 0 : uint8_t type;
33 0 : uint32_t domain:4;
34 0 : uint32_t level:4;
35 0 : uint32_t package_len:16;
36 0 : uint32_t data_len:16;
37 0 : uintptr_t source;
38 0 : log_timestamp_t timestamp;
39 : } __packed;
40 :
41 : /**
42 : * Output for one dictionary based log message about
43 : * dropped messages.
44 : */
45 1 : struct log_dict_output_dropped_msg_t {
46 0 : uint8_t type;
47 0 : uint16_t num_dropped_messages;
48 : } __packed;
49 :
50 : /** @brief Process log messages v2 for dictionary-based logging.
51 : *
52 : * Function is using provided context with the buffer and output function to
53 : * process formatted string and output the data.
54 : *
55 : * @param log_output Pointer to the log output instance.
56 : * @param msg Log message.
57 : * @param flags Optional flags.
58 : */
59 1 : void log_dict_output_msg_process(const struct log_output *log_output,
60 : struct log_msg *msg, uint32_t flags);
61 :
62 : /** @brief Process dropped messages indication for dictionary-based logging.
63 : *
64 : * Function prints error message indicating lost log messages.
65 : *
66 : * @param output Pointer to the log output instance.
67 : * @param cnt Number of dropped messages.
68 : */
69 1 : void log_dict_output_dropped_process(const struct log_output *output, uint32_t cnt);
70 :
71 : #ifdef __cplusplus
72 : }
73 : #endif
74 :
75 : #endif /* ZEPHYR_INCLUDE_LOGGING_LOG_OUTPUT_DICT_H_ */
|