Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
log_output.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_OUTPUT_H_
7#define ZEPHYR_INCLUDE_LOGGING_LOG_OUTPUT_H_
8
9#include <logging/log_msg.h>
10#include <sys/util.h>
11#include <stdarg.h>
12#include <sys/atomic.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
28#define LOG_OUTPUT_FLAG_COLORS BIT(0)
29
31#define LOG_OUTPUT_FLAG_TIMESTAMP BIT(1)
32
34#define LOG_OUTPUT_FLAG_FORMAT_TIMESTAMP BIT(2)
35
37#define LOG_OUTPUT_FLAG_LEVEL BIT(3)
38
40#define LOG_OUTPUT_FLAG_CRLF_NONE BIT(4)
41
43#define LOG_OUTPUT_FLAG_CRLF_LFONLY BIT(5)
44
47#define LOG_OUTPUT_FLAG_FORMAT_SYSLOG BIT(6)
48
51#define LOG_OUTPUT_FLAG_FORMAT_SYST BIT(7)
52
66typedef int (*log_output_func_t)(uint8_t *buf, size_t size, void *ctx);
67
68/* @brief Control block structure for log_output instance. */
71 void *ctx;
72 const char *hostname;
73};
74
76struct log_output {
80 size_t size;
81};
82
90#define LOG_OUTPUT_DEFINE(_name, _func, _buf, _size) \
91 static struct log_output_control_block _name##_control_block; \
92 static const struct log_output _name = { \
93 .func = _func, \
94 .control_block = &_name##_control_block, \
95 .buf = _buf, \
96 .size = _size, \
97 }
98
108void log_output_msg_process(const struct log_output *output,
109 struct log_msg *msg,
111
122 struct log_msg2 *msg, uint32_t flags);
123
137void log_output_string(const struct log_output *output,
138 struct log_msg_ids src_level, uint32_t timestamp,
139 const char *fmt, va_list ap, uint32_t flags);
140
155void log_output_hexdump(const struct log_output *output,
156 struct log_msg_ids src_level, uint32_t timestamp,
157 const char *metadata, const uint8_t *data,
158 uint32_t length, uint32_t flags);
159
167void log_output_dropped_process(const struct log_output *output, uint32_t cnt);
168
173void log_output_flush(const struct log_output *output);
174
180static inline void log_output_ctx_set(const struct log_output *output,
181 void *ctx)
182{
183 output->control_block->ctx = ctx;
184}
185
191static inline void log_output_hostname_set(const struct log_output *output,
192 const char *hostname)
193{
195}
196
202
210
216#ifdef __cplusplus
217}
218#endif
219
220#endif /* ZEPHYR_INCLUDE_LOGGING_LOG_OUTPUT_H_ */
int atomic_t
Definition: atomic.h:21
void log_output_dropped_process(const struct log_output *output, uint32_t cnt)
Process dropped messages indication.
void log_output_flush(const struct log_output *output)
Flush output buffer.
static void log_output_hostname_set(const struct log_output *output, const char *hostname)
Function for setting hostname of this device.
Definition: log_output.h:191
void log_output_timestamp_freq_set(uint32_t freq)
Set timestamp frequency.
void log_output_hexdump(const struct log_output *output, struct log_msg_ids src_level, uint32_t timestamp, const char *metadata, const uint8_t *data, uint32_t length, uint32_t flags)
Process log hexdump.
void log_output_msg_process(const struct log_output *output, struct log_msg *msg, uint32_t flags)
Process log messages to readable strings.
void log_output_msg2_process(const struct log_output *log_output, struct log_msg2 *msg, uint32_t flags)
Process log messages v2 to readable strings.
static void log_output_ctx_set(const struct log_output *output, void *ctx)
Function for setting user context passed to the output function.
Definition: log_output.h:180
void log_output_string(const struct log_output *output, struct log_msg_ids src_level, uint32_t timestamp, const char *fmt, va_list ap, uint32_t flags)
Process log string.
uint64_t log_output_timestamp_to_us(uint32_t timestamp)
Convert timestamp of the message to us.
int(* log_output_func_t)(uint8_t *buf, size_t size, void *ctx)
Prototype of the function processing output data.
Definition: log_output.h:66
flags
Definition: http_parser.h:131
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Definition: log_msg2.h:105
Part of log message header identifying source and level.
Definition: log_msg.h:85
Log message structure.
Definition: log_msg.h:139
Definition: log_output.h:69
atomic_t offset
Definition: log_output.h:70
const char * hostname
Definition: log_output.h:72
void * ctx
Definition: log_output.h:71
Log_output instance structure.
Definition: log_output.h:76
struct log_output_control_block * control_block
Definition: log_output.h:78
log_output_func_t func
Definition: log_output.h:77
uint8_t * buf
Definition: log_output.h:79
size_t size
Definition: log_output.h:80
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
Misc utilities.