Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Formatting of log messages into human-readable or structured output. More...

Topics

 Log output formatting flags.

Files

file  log_output.h
 Header file for the log output formatter.
file  log_output_custom.h
 Header file for custom log output formatting.
file  log_output_dict.h
 Header file for dictionary-based log output.

Data Structures

struct  log_output_control_block
 Run-time control block for a Log output instance. More...
struct  log_output
 Log output instance. More...
struct  log_dict_output_normal_msg_hdr_t
 On-wire header for one dictionary-based log message. More...
struct  log_dict_output_dropped_msg_t
 On-wire dictionary-based message reporting dropped messages. More...

Macros

#define LOG_OUTPUT_DEFINE(_name, _func, _buf, _size)
 Create log_output instance.

Typedefs

typedef int(* log_output_func_t) (uint8_t *buf, size_t size, void *ctx)
 Prototype of the function processing output data.
typedef void(* log_format_func_t) (const struct log_output *output, struct log_msg *msg, uint32_t flags)
 Typedef of the function pointer table "format_table".

Enumerations

enum  log_dict_output_msg_type { MSG_NORMAL = 0 , MSG_DROPPED_MSG = 1 }
 Dictionary output message type. More...

Functions

log_format_func_t log_format_func_t_get (uint32_t log_type)
 Declaration of the get routine for function pointer table format_table.
void log_output_msg_process (const struct log_output *log_output, struct log_msg *msg, uint32_t flags)
 Process log messages v2 to readable strings.
void log_output_process (const struct log_output *log_output, log_timestamp_t timestamp, const char *domain, const char *source, k_tid_t tid, uint8_t core_id, uint8_t level, const uint8_t *package, const uint8_t *data, size_t data_len, uint32_t flags)
 Process input data to a readable string.
void log_output_msg_syst_process (const struct log_output *log_output, struct log_msg *msg, uint32_t flags)
 Process log messages v2 to SYS-T format.
void log_output_dropped_process (const struct log_output *output, uint32_t cnt)
 Process dropped messages indication.
static void log_output_write (log_output_func_t outf, uint8_t *buf, size_t len, void *ctx)
 Write to the output buffer.
static void log_output_flush (const struct log_output *output)
 Flush output buffer.
static void log_output_ctx_set (const struct log_output *output, void *ctx)
 Function for setting user context passed to the output function.
static void log_output_hostname_set (const struct log_output *output, const char *hostname)
 Function for setting hostname of this device.
void log_output_timestamp_freq_set (uint32_t freq)
 Set timestamp frequency.
uint64_t log_output_timestamp_to_us (log_timestamp_t timestamp)
 Convert timestamp of the message to us.
void log_dict_output_msg_process (const struct log_output *log_output, struct log_msg *msg, uint32_t flags)
 Process log messages v2 for dictionary-based logging.
void log_dict_output_dropped_process (const struct log_output *output, uint32_t cnt)
 Process dropped messages indication for dictionary-based logging.
void log_custom_output_msg_process (const struct log_output *log_output, struct log_msg *msg, uint32_t flags)
 Custom logging output formatting.

Output format types

Values used with log_format_set() and log_backend_format_set() to select the output format of a backend at run time.

#define LOG_OUTPUT_TEXT   0
 Plain text output format.
#define LOG_OUTPUT_SYST   1
 MIPI Sys-T output format.
#define LOG_OUTPUT_DICT   2
 Dictionary-based (binary) output format.
#define LOG_OUTPUT_CUSTOM   3
 Custom, user-provided output format.

Detailed Description

Formatting of log messages into human-readable or structured output.

Macro Definition Documentation

◆ LOG_OUTPUT_CUSTOM

#define LOG_OUTPUT_CUSTOM   3

#include <zephyr/logging/log_output.h>

Custom, user-provided output format.

◆ LOG_OUTPUT_DEFINE

#define LOG_OUTPUT_DEFINE ( _name,
_func,
_buf,
_size )

#include <zephyr/logging/log_output.h>

Value:
static struct log_output_control_block _name##_control_block; \
static const struct log_output _name = { \
.func = _func, \
.control_block = &_name##_control_block, \
.buf = _buf, \
.size = _size, \
}
Run-time control block for a Log output instance.
Definition log_output.h:110
Log output instance.
Definition log_output.h:119
uint8_t * buf
Buffer holding formatted output before it is written.
Definition log_output.h:122

Create log_output instance.

Parameters
_nameInstance name.
_funcFunction for processing output data.
_bufPointer to the output buffer.
_sizeSize of the output buffer.

◆ LOG_OUTPUT_DICT

#define LOG_OUTPUT_DICT   2

#include <zephyr/logging/log_output.h>

Dictionary-based (binary) output format.

◆ LOG_OUTPUT_SYST

#define LOG_OUTPUT_SYST   1

#include <zephyr/logging/log_output.h>

MIPI Sys-T output format.

◆ LOG_OUTPUT_TEXT

#define LOG_OUTPUT_TEXT   0

#include <zephyr/logging/log_output.h>

Plain text output format.

Typedef Documentation

◆ log_format_func_t

typedef void(* log_format_func_t) (const struct log_output *output, struct log_msg *msg, uint32_t flags)

#include <zephyr/logging/log_output.h>

Typedef of the function pointer table "format_table".

Parameters
outputPointer to log_output struct.
msgPointer to log_msg struct.
flagsFlags used for text formatting options.
Returns
Function pointer based on Kconfigs defined for backends.

◆ log_output_func_t

typedef int(* log_output_func_t) (uint8_t *buf, size_t size, void *ctx)

#include <zephyr/logging/log_output.h>

Prototype of the function processing output data.

Parameters
bufThe buffer data.
sizeThe buffer size.
ctxUser context.
Returns
Number of bytes processed, dropped or discarded.
Note
If the log output function cannot process all of the data, it is its responsibility to mark them as dropped or discarded by returning the corresponding number of bytes dropped or discarded to the caller.

Enumeration Type Documentation

◆ log_dict_output_msg_type

#include <zephyr/logging/log_output_dict.h>

Dictionary output message type.

Enumerator
MSG_NORMAL 

Normal log message.

MSG_DROPPED_MSG 

Notification about dropped messages.

Function Documentation

◆ log_custom_output_msg_process()

void log_custom_output_msg_process ( const struct log_output * log_output,
struct log_msg * msg,
uint32_t flags )

#include <zephyr/logging/log_output_custom.h>

Custom logging output formatting.

Process log messages from an external output function set with log_custom_output_msg_set

Function is using provided context with the buffer and output function to process formatted string and output the data.

Parameters
log_outputPointer to the log output instance.
msgLog message.
flagsOptional flags.

◆ log_dict_output_dropped_process()

void log_dict_output_dropped_process ( const struct log_output * output,
uint32_t cnt )

#include <zephyr/logging/log_output_dict.h>

Process dropped messages indication for dictionary-based logging.

Function prints error message indicating lost log messages.

Parameters
outputPointer to the log output instance.
cntNumber of dropped messages.

◆ log_dict_output_msg_process()

void log_dict_output_msg_process ( const struct log_output * log_output,
struct log_msg * msg,
uint32_t flags )

#include <zephyr/logging/log_output_dict.h>

Process log messages v2 for dictionary-based logging.

Function is using provided context with the buffer and output function to process formatted string and output the data.

Parameters
log_outputPointer to the log output instance.
msgLog message.
flagsOptional flags.

◆ log_format_func_t_get()

log_format_func_t log_format_func_t_get ( uint32_t log_type)

#include <zephyr/logging/log_output.h>

Declaration of the get routine for function pointer table format_table.

◆ log_output_ctx_set()

void log_output_ctx_set ( const struct log_output * output,
void * ctx )
inlinestatic

#include <zephyr/logging/log_output.h>

Function for setting user context passed to the output function.

Parameters
outputPointer to the log output instance.
ctxUser context.

◆ log_output_dropped_process()

void log_output_dropped_process ( const struct log_output * output,
uint32_t cnt )

#include <zephyr/logging/log_output.h>

Process dropped messages indication.

Function prints error message indicating lost log messages.

Parameters
outputPointer to the log output instance.
cntNumber of dropped messages.

◆ log_output_flush()

void log_output_flush ( const struct log_output * output)
inlinestatic

#include <zephyr/logging/log_output.h>

Flush output buffer.

Parameters
outputPointer to the log output instance.

◆ log_output_hostname_set()

void log_output_hostname_set ( const struct log_output * output,
const char * hostname )
inlinestatic

#include <zephyr/logging/log_output.h>

Function for setting hostname of this device.

Parameters
outputPointer to the log output instance.
hostnameHostname of this device

◆ log_output_msg_process()

void log_output_msg_process ( const struct log_output * log_output,
struct log_msg * msg,
uint32_t flags )

#include <zephyr/logging/log_output.h>

Process log messages v2 to readable strings.

Function is using provided context with the buffer and output function to process formatted string and output the data.

Parameters
log_outputPointer to the log output instance.
msgLog message.
flagsOptional flags. See Log output formatting flags..

◆ log_output_msg_syst_process()

void log_output_msg_syst_process ( const struct log_output * log_output,
struct log_msg * msg,
uint32_t flags )

#include <zephyr/logging/log_output.h>

Process log messages v2 to SYS-T format.

Function is using provided context with the buffer and output function to process formatted string and output the data in sys-t log output format.

Parameters
log_outputPointer to the log output instance.
msgLog message.
flagsOptional flags. See Log output formatting flags..

◆ log_output_process()

void log_output_process ( const struct log_output * log_output,
log_timestamp_t timestamp,
const char * domain,
const char * source,
k_tid_t tid,
uint8_t core_id,
uint8_t level,
const uint8_t * package,
const uint8_t * data,
size_t data_len,
uint32_t flags )

#include <zephyr/logging/log_output.h>

Process input data to a readable string.

Parameters
log_outputPointer to the log output instance.
timestampTimestamp.
domainDomain name string. Can be NULL.
sourceSource name string. Can be NULL.
tidThread ID.
core_idCore ID.
levelCriticality level.
packageCbprintf package with a logging message string.
dataData passed to hexdump API. Can be NULL.
data_lenData length.
flagsFormatting flags. See Log output formatting flags..

◆ log_output_timestamp_freq_set()

void log_output_timestamp_freq_set ( uint32_t freq)

#include <zephyr/logging/log_output.h>

Set timestamp frequency.

Parameters
freqFrequency in Hz.

◆ log_output_timestamp_to_us()

uint64_t log_output_timestamp_to_us ( log_timestamp_t timestamp)

#include <zephyr/logging/log_output.h>

Convert timestamp of the message to us.

Parameters
timestampMessage timestamp
Returns
Timestamp value in us.

◆ log_output_write()

void log_output_write ( log_output_func_t outf,
uint8_t * buf,
size_t len,
void * ctx )
inlinestatic

#include <zephyr/logging/log_output.h>

Write to the output buffer.

Parameters
outfOutput function.
bufBuffer.
lenBuffer length.
ctxContext passed to the p outf.