From fff5caa73977e8a6f2537a5a459fb13af5397385 Mon Sep 17 00:00:00 2001 From: Martin Willers Date: Tue, 16 Mar 2021 00:53:55 +0100 Subject: Add verbose mode attribute handling (#292) dlt_user_log_write_*_attr() enables to writing these types, but also support adding "attributes" for them, i.e. a "name" and a "unit". Signed-off-by: Martin Willers --- include/dlt/dlt_user.h.in | 216 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) (limited to 'include/dlt/dlt_user.h.in') diff --git a/include/dlt/dlt_user.h.in b/include/dlt/dlt_user.h.in index e4b2c5a..817cf11 100644 --- a/include/dlt/dlt_user.h.in +++ b/include/dlt/dlt_user.h.in @@ -313,6 +313,21 @@ DltReturnValue dlt_user_log_write_finish(DltContextData *log); */ DltReturnValue dlt_user_log_write_bool(DltContextData *log, uint8_t data); +/** + * Write a boolean parameter with "name" attribute into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param data boolean parameter written into log message (mapped to uint8) + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_bool_attr(DltContextData *log, uint8_t data, const char *name); + /** * Write a float parameter into a DLT log message. * dlt_user_log_write_start has to be called before adding any attributes to the log message. @@ -333,6 +348,38 @@ DltReturnValue dlt_user_log_write_float32(DltContextData *log, float32_t data); */ DltReturnValue dlt_user_log_write_float64(DltContextData *log, double data); +/** + * Write a float parameter with attributes into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name or @a unit is NULL, this function will add a corresponding attribute field with length 0 + * and no content to the message for that attribute. + * + * @param log pointer to an object containing information about logging context data + * @param data float32_t parameter written into log message + * @param name the "name" attribute (or NULL) + * @param unit the "unit" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_float32_attr(DltContextData *log, float32_t data, const char *name, const char *unit); + +/** + * Write a double parameter with attributes into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name or @a unit is NULL, this function will add a corresponding attribute field with length 0 + * and no content to the message for that attribute. + * + * @param log pointer to an object containing information about logging context data + * @param data float64_t parameter written into log message + * @param name the "name" attribute (or NULL) + * @param unit the "unit" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_float64_attr(DltContextData *log, float64_t data, const char *name, const char *unit); + /** * Write a uint parameter into a DLT log message. * dlt_user_log_write_start has to be called before adding any attributes to the log message. @@ -347,6 +394,26 @@ DltReturnValue dlt_user_log_write_uint16(DltContextData *log, uint16_t data); DltReturnValue dlt_user_log_write_uint32(DltContextData *log, uint32_t data); DltReturnValue dlt_user_log_write_uint64(DltContextData *log, uint64_t data); +/** + * Write a uint parameter with attributes into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name or @a unit is NULL, this function will add a corresponding attribute field with length 0 + * and no content to the message for that attribute. + * + * @param log pointer to an object containing information about logging context data + * @param data unsigned int parameter written into log message + * @param name the "name" attribute (or NULL) + * @param unit the "unit" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_uint_attr(DltContextData *log, unsigned int data, const char *name, const char *unit); +DltReturnValue dlt_user_log_write_uint8_attr(DltContextData *log, uint8_t data, const char *name, const char *unit); +DltReturnValue dlt_user_log_write_uint16_attr(DltContextData *log, uint16_t data, const char *name, const char *unit); +DltReturnValue dlt_user_log_write_uint32_attr(DltContextData *log, uint32_t data, const char *name, const char *unit); +DltReturnValue dlt_user_log_write_uint64_attr(DltContextData *log, uint64_t data, const char *name, const char *unit); + /** * Write a uint parameter into a DLT log message. The output will be formatted as given by the parameter type. * dlt_user_log_write_start has to be called before adding any attributes to the log message. @@ -384,6 +451,27 @@ DltReturnValue dlt_user_log_write_int8(DltContextData *log, int8_t data); DltReturnValue dlt_user_log_write_int16(DltContextData *log, int16_t data); DltReturnValue dlt_user_log_write_int32(DltContextData *log, int32_t data); DltReturnValue dlt_user_log_write_int64(DltContextData *log, int64_t data); + +/** + * Write an int parameter with attributes into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name or @a unit is NULL, this function will add a corresponding attribute field with length 0 + * and no content to the message for that attribute. + * + * @param log pointer to an object containing information about logging context data + * @param data int parameter written into log message + * @param name the "name" attribute (or NULL) + * @param unit the "unit" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_int_attr(DltContextData *log, int data, const char *name, const char *unit); +DltReturnValue dlt_user_log_write_int8_attr(DltContextData *log, int8_t data, const char *name, const char *unit); +DltReturnValue dlt_user_log_write_int16_attr(DltContextData *log, int16_t data, const char *name, const char *unit); +DltReturnValue dlt_user_log_write_int32_attr(DltContextData *log, int32_t data, const char *name, const char *unit); +DltReturnValue dlt_user_log_write_int64_attr(DltContextData *log, int64_t data, const char *name, const char *unit); + /** * Write a null terminated ASCII string into a DLT log message. * dlt_user_log_write_start has to be called before adding any attributes to the log message. @@ -449,6 +537,101 @@ DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *t */ DltReturnValue dlt_user_log_write_sized_utf8_string(DltContextData *log, const char *text, uint16_t length); +/** + * Write a null-terminated ASCII string with "name" attribute into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param text pointer to the parameter written into log message containing null termination + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_string_attr(DltContextData *log, const char *text, const char *name); + +/** + * Write a potentially non-null-terminated ASCII string with "name" attribute into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param text pointer to the parameter written into log message + * @param length length in bytes of @a text (without any termination character) + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_sized_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name); + +/** + * Write a constant, null-terminated ASCII string with "name" attribute into a DLT log message. + * In non-verbose mode, this parameter will not be sent at all. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param text pointer to the parameter written into log message containing null termination + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_constant_string_attr(DltContextData *log, const char *text, const char *name); + +/** + * Write a constant, potentially non-null-terminated ASCII string with "name" attribute into a DLT log message. + * In non-verbose mode, this parameter will not be sent at all. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param text pointer to the parameter written into log message containing null termination + * @param length length in bytes of @a text (without any termination character) + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_sized_constant_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name); + +/** + * Write a null-terminated UTF-8 string with "name" attribute into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param text pointer to the parameter written into log message containing null termination + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_utf8_string_attr(DltContextData *log, const char *text, const char *name); + +/** + * Write a potentially non-null-terminated UTF-8 string with "name" attribute into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param text pointer to the parameter written into log message + * @param length length in bytes of @a text (without any termination character) + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_sized_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name); + /** * Write a binary memory block into a DLT log message. * dlt_user_log_write_start has to be called before adding any attributes to the log message. @@ -472,6 +655,39 @@ DltReturnValue dlt_user_log_write_raw(DltContextData *log, void *data, uint16_t */ DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log, void *data, uint16_t length, DltFormatType type); +/** + * Write a binary memory block with "name" attribute into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param data pointer to the parameter written into log message. + * @param length length in bytes of the parameter written into log message + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_raw_attr(DltContextData *log, const void *data, uint16_t length, const char *name); + +/** + * Write a binary memory block with "name" attribute into a DLT log message. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @param log pointer to an object containing information about logging context data + * @param data pointer to the parameter written into log message. + * @param length length in bytes of the parameter written into log message + * @param type the format information + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_raw_formatted_attr(DltContextData *log, const void *data, uint16_t length, DltFormatType type, const char *name); + /** * Trace network message * @param handle pointer to an object containing information about one special logging context -- cgit v1.2.1