summaryrefslogtreecommitdiff
path: root/include/dlt
diff options
context:
space:
mode:
Diffstat (limited to 'include/dlt')
-rw-r--r--include/dlt/dlt_common.h12
-rw-r--r--include/dlt/dlt_user.h.in216
-rw-r--r--include/dlt/dlt_user_macros.h137
3 files changed, 364 insertions, 1 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h
index 3e7100e..049b6ee 100644
--- a/include/dlt/dlt_common.h
+++ b/include/dlt/dlt_common.h
@@ -75,6 +75,7 @@
# include <netinet/in.h>
# include <stdio.h>
+# include <stdbool.h>
# ifdef __linux__
# include <linux/limits.h>
# include <sys/socket.h>
@@ -89,8 +90,10 @@
# if defined(__GNUC__)
# define PURE_FUNCTION __attribute__((pure))
+# define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, a, b)))
# else
# define PURE_FUNCTION /* nothing */
+# define PRINTF_FORMAT(a,b) /* nothing */
# endif
# if !defined (__WIN32__) && !defined(_MSC_VER)
@@ -1170,6 +1173,13 @@ void dlt_log_set_fifo_basedir(const char *pipe_dir);
* @param level the level
*/
void dlt_log_set_level(int level);
+
+/**
+ * Set whether to print "name" and "unit" attributes in console output
+ * @param state true = with attributes, false = without attributes
+ */
+void dlt_print_with_attributes(bool state);
+
/**
* Initialize (external) logging facility
* @param mode positive, 0 = log to stdout, 1 = log to syslog, 2 = log to file, 3 = log to stderr
@@ -1180,7 +1190,7 @@ void dlt_log_init(int mode);
* @param format format string for message
* @return negative value if there was an error or the total number of characters written is returned on success
*/
-int dlt_user_printf(const char *format, ...);
+int dlt_user_printf(const char *format, ...) PRINTF_FORMAT(1,2);
/**
* Log ASCII string with null-termination to (external) logging facility
* @param prio priority (see syslog() call)
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
@@ -314,6 +314,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.
* Finish sending log message by calling dlt_user_log_write_finish.
@@ -334,6 +349,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.
* Finish sending log message by calling dlt_user_log_write_finish.
@@ -348,6 +395,26 @@ 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.
* Finish sending log message by calling dlt_user_log_write_finish.
@@ -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.
@@ -450,6 +538,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.
* Finish sending log message by calling dlt_user_log_write_finish.
@@ -473,6 +656,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
* @param nw_trace_type type of network trace (DLT_NW_TRACE_IPC, DLT_NW_TRACE_CAN, DLT_NW_TRACE_FLEXRAY, or DLT_NW_TRACE_MOST)
diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h
index f313270..24b7b7a 100644
--- a/include/dlt/dlt_user_macros.h
+++ b/include/dlt/dlt_user_macros.h
@@ -369,6 +369,66 @@
(void)dlt_user_log_write_sized_utf8_string(&log_local, TEXT, LEN)
/**
+ * Add string parameter with "name" attribute to the log messsage.
+ * @param TEXT ASCII string
+ * @param NAME "name" attribute
+ */
+#define DLT_STRING_ATTR(TEXT, NAME) \
+ (void)dlt_user_log_write_string_attr(&log_local, TEXT, NAME)
+
+/**
+ * Add string parameter with given length and "name" attribute to the log messsage.
+ * The string in @a TEXT does not need to be null-terminated, but
+ * the copied string will be null-terminated at its destination
+ * in the message buffer.
+ * @param TEXT ASCII string
+ * @param LEN length in bytes to take from @a TEXT
+ * @param NAME "name" attribute
+ */
+#define DLT_SIZED_STRING_ATTR(TEXT, LEN, NAME) \
+ (void)dlt_user_log_write_sized_string_attr(&log_local, TEXT, LEN, NAME)
+
+/**
+ * Add constant string parameter with "name" attribute to the log messsage.
+ * @param TEXT Constant ASCII string
+ * @param NAME "name" attribute
+ */
+#define DLT_CSTRING_ATTR(TEXT, NAME) \
+ (void)dlt_user_log_write_constant_string_attr(&log_local, TEXT, NAME)
+
+/**
+ * Add constant string parameter with given length and "name" attribute to the log messsage.
+ * The string in @a TEXT does not need to be null-terminated, but
+ * the copied string will be null-terminated at its destination
+ * in the message buffer.
+ * @param TEXT Constant ASCII string
+ * @param LEN length in bytes to take from @a TEXT
+ * @param NAME "name" attribute
+ */
+#define DLT_SIZED_CSTRING_ATTR(TEXT, LEN, NAME) \
+ (void)dlt_user_log_write_sized_constant_string_attr(&log_local, TEXT, LEN, NAME)
+
+/**
+ * Add utf8-encoded string parameter with "name" attribute to the log messsage.
+ * @param TEXT UTF8-encoded string
+ * @param NAME "name" attribute
+ */
+#define DLT_UTF8_ATTR(TEXT, NAME) \
+ (void)dlt_user_log_write_utf8_string_attr(&log_local, TEXT, NAME)
+
+/**
+ * Add utf8-encoded string parameter with given length and "name" attribute to the log messsage.
+ * The string in @a TEXT does not need to be null-terminated, but
+ * the copied string will be null-terminated at its destination
+ * in the message buffer.
+ * @param TEXT UTF8-encoded string
+ * @param LEN length in bytes to take from @a TEXT
+ * @param NAME "name" attribute
+ */
+#define DLT_SIZED_UTF8_ATTR(TEXT, LEN, NAME) \
+ (void)dlt_user_log_write_sized_utf8_string_attr(&log_local, TEXT, LEN, ATTR)
+
+/**
* Add boolean parameter to the log messsage.
* @param BOOL_VAR Boolean value (mapped to uint8)
*/
@@ -376,6 +436,14 @@
(void)dlt_user_log_write_bool(&log_local, BOOL_VAR)
/**
+ * Add boolean parameter with "name" attribute to the log messsage.
+ * @param BOOL_VAR Boolean value (mapped to uint8)
+ * @param NAME "name" attribute
+ */
+#define DLT_BOOL_ATTR(BOOL_VAR, NAME) \
+ (void)dlt_user_log_write_bool_attr(&log_local, BOOL_VAR, NAME)
+
+/**
* Add float32 parameter to the log messsage.
* @param FLOAT32_VAR Float32 value (mapped to float)
*/
@@ -390,6 +458,24 @@
(void)dlt_user_log_write_float64(&log_local, FLOAT64_VAR)
/**
+ * Add float32 parameter with attributes to the log messsage.
+ * @param FLOAT32_VAR Float32 value (mapped to float)
+ * @param NAME "name" attribute
+ * @param UNIT "unit" attribute
+ */
+#define DLT_FLOAT32_ATTR(FLOAT32_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_float32_attr(&log_local, FLOAT32_VAR, NAME, UNIT)
+
+/**
+ * Add float64 parameter with attributes to the log messsage.
+ * @param FLOAT64_VAR Float64 value (mapped to double)
+ * @param NAME "name" attribute
+ * @param UNIT "unit" attribute
+ */
+#define DLT_FLOAT64_ATTR(FLOAT64_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_float64_attr(&log_local, FLOAT64_VAR, NAME, UNIT)
+
+/**
* Add integer parameter to the log messsage.
* @param INT_VAR integer value
*/
@@ -409,6 +495,27 @@
(void)dlt_user_log_write_int64(&log_local, INT_VAR)
/**
+ * Add integer parameter with attributes to the log messsage.
+ * @param INT_VAR integer value
+ * @param NAME "name" attribute
+ * @param UNIT "unit" attribute
+ */
+#define DLT_INT_ATTR(INT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_int_attr(&log_local, INT_VAR, NAME, UNIT)
+
+#define DLT_INT8_ATTR(INT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_int8_attr(&log_local, INT_VAR, NAME, UNIT)
+
+#define DLT_INT16_ATTR(INT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_int16_attr(&log_local, INT_VAR, NAME, UNIT)
+
+#define DLT_INT32_ATTR(INT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_int32_attr(&log_local, INT_VAR, NAME, UNIT)
+
+#define DLT_INT64_ATTR(INT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_int64_attr(&log_local, INT_VAR, NAME, UNIT)
+
+/**
* Add unsigned integer parameter to the log messsage.
* @param UINT_VAR unsigned integer value
*/
@@ -428,6 +535,27 @@
(void)dlt_user_log_write_uint64(&log_local, UINT_VAR)
/**
+ * Add unsigned integer parameter with attributes to the log messsage.
+ * @param UINT_VAR unsigned integer value
+ * @param NAME "name" attribute
+ * @param UNIT "unit" attribute
+ */
+#define DLT_UINT_ATTR(UINT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_uint_attr(&log_local, UINT_VAR, NAME, UNIT)
+
+#define DLT_UINT8_ATTR(UINT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_uint8_attr(&log_local, UINT_VAR, NAME, UNIT)
+
+#define DLT_UINT16_ATTR(UINT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_uint16_attr(&log_local, UINT_VAR, NAME, UNIT)
+
+#define DLT_UINT32_ATTR(UINT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_uint32_attr(&log_local, UINT_VAR, NAME, UNIT)
+
+#define DLT_UINT64_ATTR(UINT_VAR, NAME, UNIT) \
+ (void)dlt_user_log_write_uint64_attr(&log_local, UINT_VAR, NAME, UNIT)
+
+/**
* Add binary memory block to the log messages.
* @param BUF pointer to memory block
* @param LEN length of memory block
@@ -448,6 +576,15 @@
(void)dlt_user_log_write_uint16_formatted(&log_local, UINT_VAR, DLT_FORMAT_BIN16)
/**
+ * Add binary memory block with "name" attribute to the log messages.
+ * @param BUF pointer to memory block
+ * @param LEN length of memory block
+ * @param NAME "name" attribute
+ */
+#define DLT_RAW_ATTR(BUF, LEN, NAME) \
+ (void)dlt_user_log_write_raw_attr(&log_local, BUF, LEN, NAME)
+
+/**
* Architecture independent macro to print pointers
*/
#define DLT_PTR(PTR_VAR) \