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

Log output API. More...

Modules

 Log output formatting flags.
 

Data Structures

struct  log_output_control_block
 
struct  log_output
 Log_output instance structure. More...
 

Macros

#define LOG_OUTPUT_TEXT   0
 Supported backend logging format types for use with log_format_set() API to switch log format at runtime.
 
#define LOG_OUTPUT_SYST   1
 
#define LOG_OUTPUT_DICT   2
 
#define LOG_OUTPUT_CUSTOM   3
 
#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".
 

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 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.
 
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_custom_output_msg_process (const struct log_output *log_output, struct log_msg *msg, uint32_t flags)
 Custom logging output formatting.
 

Detailed Description

Log output API.

Macro Definition Documentation

◆ LOG_OUTPUT_CUSTOM

#define LOG_OUTPUT_CUSTOM   3

◆ 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, \
}
Definition: log_output.h:89
Log_output instance structure.
Definition: log_output.h:96
log_output_func_t func
Definition: log_output.h:97
uint8_t * buf
Definition: log_output.h:99

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

◆ LOG_OUTPUT_SYST

#define LOG_OUTPUT_SYST   1

◆ LOG_OUTPUT_TEXT

#define LOG_OUTPUT_TEXT   0

#include <zephyr/logging/log_output.h>

Supported backend logging format types for use with log_format_set() API to switch log format at runtime.

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.

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_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()

static 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)

#include <zephyr/logging/log_output.h>

Flush output buffer.

Parameters
outputPointer to the log output instance.

◆ log_output_hostname_set()

static 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  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.
levelCriticality level.
packageCbprintf package with a logging message string.
dataData passed to hexdump API. Can bu 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.