|
| 1 | +/* |
| 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 <logging/log_output.h> |
| 11 | +#include <logging/log_msg2.h> |
| 12 | +#include <stdarg.h> |
| 13 | +#include <toolchain.h> |
| 14 | +#include <sys/util.h> |
| 15 | + |
| 16 | +#ifdef __cplusplus |
| 17 | +extern "C" { |
| 18 | +#endif |
| 19 | + |
| 20 | +/** |
| 21 | + * Log message type |
| 22 | + */ |
| 23 | +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 | +struct log_dict_output_normal_msg_hdr_t { |
| 32 | + uint8_t type; |
| 33 | + uint32_t domain:3; |
| 34 | + uint32_t level:3; |
| 35 | + uint32_t package_len:10; |
| 36 | + uint32_t data_len:12; |
| 37 | + uintptr_t source; |
| 38 | + log_timestamp_t timestamp; |
| 39 | +} __packed; |
| 40 | + |
| 41 | +/** |
| 42 | + * Output for one dictionary based log message about |
| 43 | + * dropped messages. |
| 44 | + */ |
| 45 | +struct log_dict_output_dropped_msg_t { |
| 46 | + uint8_t type; |
| 47 | + uint16_t num_dropped_messages; |
| 48 | +} __packed; |
| 49 | + |
| 50 | +/** @brief Process log messages v2 for dictionary-basde 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 | +void log_dict_output_msg2_process(const struct log_output *log_output, |
| 60 | + struct log_msg2 *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 | +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_ */ |
0 commit comments