From 3c3ead84aa51abc8d95c5ee974182194949f63c9 Mon Sep 17 00:00:00 2001 From: Saya Sugiura Date: Fri, 26 Mar 2021 02:52:13 +0000 Subject: lib: Add new interfaces with given buffer This commit adds new interfaces: - dlt_user_log_write_start_w_given_buffer(): accepts a log buffer as an input. - dlt_user_log_write_finish_w_given_buffer(): finalizes logging and send the message to corresponding output This is to reduce DLT API calls in DLT application as much as possible and avoid allocating dynamic memory within DLT library. The log buffer has to be prepared in DLT application in order to use these interfaces. Signed-off-by: Saya Sugiura --- include/dlt/dlt_user.h.in | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include') diff --git a/include/dlt/dlt_user.h.in b/include/dlt/dlt_user.h.in index 30eb234..7a2d35e 100644 --- a/include/dlt/dlt_user.h.in +++ b/include/dlt/dlt_user.h.in @@ -297,6 +297,30 @@ DltReturnValue dlt_user_log_write_start_id(DltContext *handle, DltLogLevelType loglevel, uint32_t messageid); +/** + * Initialize the generation of a DLT log message with given buffer from DLT application. + * This can be considered as replacement of dlt_user_log_write_start/dlt_user_log_write_start_id + * and other data functions like dlt_user_log_write_string. The fourth, fifth, and sixth arguments + * shall be prepared by DLT application; this function is only responsible for checking log + * level and setting the given values to context data. This function has to be called first, + * when an application is ready to send a new log message with given buffer. This function only + * works with combination of dlt_user_log_write_finish_w_given_buffer and the function must only be + * called, when return value is bigger than zero. The function only supports verbose mode as of now. + * @param handle pointer to an object containing information about one special logging context + * @param log pointer to an object containing information about logging context data + * @param loglevel this is the current log level of the log message to be sent + * @param buffer data with log message + * @param size buffer size + * @param args_num number of arguments in buffer + * @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is matching + */ +DltReturnValue dlt_user_log_write_start_w_given_buffer(DltContext *handle, + DltContextData *log, + DltLogLevelType loglevel, + char *buffer, + size_t size, + int32_t args_num); + /** * Finishing the generation of a DLT log message and sending it to the DLT daemon. * This function has to be called after writing all the log attributes of a log message. @@ -305,6 +329,16 @@ DltReturnValue dlt_user_log_write_start_id(DltContext *handle, */ DltReturnValue dlt_user_log_write_finish(DltContextData *log); +/** + * Finishing the generation of a DLT log message and sending it to the DLT daemon without + * freeing log buffer. This function only works with combination of + * dlt_user_log_write_start_w_given_buffer. This function has to be called after writing all + * the log attributes of a log message. + * @param log pointer to an object containing information about logging context data + * @return Value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_finish_w_given_buffer(DltContextData *log); + /** * Write a boolean parameter into a DLT log message. * dlt_user_log_write_start has to be called before adding any attributes to the log message. -- cgit v1.2.1