udpc_write()

udpc_write()#

udpc_write() sends a log message over UDP, formatting it according to the specified output format.

Prototype

int udpc_write(
    udpc_t      udpc,
    int         priority,
    const char *bf,
    size_t      len
);

Parameters

Key

Type

Description

udpc

udpc_t

A handle to the UDP client instance.

priority

int

The priority level of the log message, ranging from LOG_EMERG to LOG_MONITOR.

bf

const char *

The log message to be sent, which must be a null-terminated string.

len

size_t

The length of the log message in bytes.


Return Value

Returns 0 on success, or -1 if an error occurs.

Notes

If the message length exceeds the buffer size, the function returns an error. The function ensures that the message is properly formatted based on the selected output_format_t. If the UDP socket is not open, udpc_write() attempts to reopen it before sending the message. Messages are sent in chunks of udp_frame_size if they exceed the frame size.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples