summaryrefslogtreecommitdiff
path: root/include/dlt/dlt_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/dlt/dlt_common.h')
-rw-r--r--include/dlt/dlt_common.h82
1 files changed, 73 insertions, 9 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h
index 9a99fce..1757873 100644
--- a/include/dlt/dlt_common.h
+++ b/include/dlt/dlt_common.h
@@ -191,13 +191,13 @@
# define LOG_DAEMON (3 << 3)
# endif
-enum {
+typedef enum {
DLT_LOG_TO_CONSOLE = 0,
DLT_LOG_TO_SYSLOG = 1,
DLT_LOG_TO_FILE = 2,
DLT_LOG_TO_STDERR = 3,
DLT_LOG_DROPPED = 4
-};
+} DltLoggingMode;
/**
* The standard TCP Port used for DLT daemon, can be overwritten via -p \<port\> when starting dlt-daemon
@@ -300,7 +300,7 @@ enum {
{ length = -1; } \
else \
{ dst = *((type *)src); src += sizeof(type); length -= sizeof(type); } \
- } while(0)
+ } while(false)
# define DLT_MSG_READ_ID(dst, src, length) \
do { \
@@ -308,7 +308,7 @@ enum {
{ length = -1; } \
else \
{ memcpy(dst, src, DLT_ID_SIZE); src += DLT_ID_SIZE; length -= DLT_ID_SIZE; } \
- } while(0)
+ } while(false)
# define DLT_MSG_READ_STRING(dst, src, maxlength, dstlength, length) \
do { \
@@ -324,7 +324,7 @@ enum {
src += length; \
maxlength -= length; \
} \
- } while(0)
+ } while(false)
# define DLT_MSG_READ_NULL(src, maxlength, length) \
do { \
@@ -332,7 +332,7 @@ enum {
{ length = -1; } \
else \
{ src += length; maxlength -= length; } \
- } while(0)
+ } while(false)
# define DLT_HEADER_SHOW_NONE 0x0000
# define DLT_HEADER_SHOW_TIME 0x0001
@@ -1195,7 +1195,7 @@ 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
*/
-void dlt_log_init(int mode);
+DltReturnValue dlt_log_init(int mode);
/**
* Print with variable arguments to specified file descriptor by DLT_LOG_MODE environment variable (like fprintf)
* @param format format string for message
@@ -1631,15 +1631,28 @@ int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count);
*/
int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count);
+
+/**
+ * Convert get log info from ASCII to string (with '\0' termination)
+ *
+ * @param rp char
+ * @param rp_count int
+ * @param wp char Array needs to be 1 byte larger than len to store '\0'
+ * @param len int
+ */
+void dlt_getloginfo_conv_ascii_to_string(char *rp, int *rp_count, char *wp, int len);
+
+
/**
- * Convert get log info from ASCII to ID
+ * Convert get log info from ASCII to ID (without '\0' termination)
*
* @param rp char
* @param rp_count int
* @param wp char
* @param len int
+ * @return position of last read character in wp
*/
-void dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len);
+int dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len);
/**
* Convert from hex ASCII to binary
@@ -1657,6 +1670,57 @@ void dlt_hex_ascii_to_binary(const char *ptr, uint8_t *binary, int *size);
*/
int dlt_execute_command(char *filename, char *command, ...);
+/**
+ * Return the extension of given file name.
+ * @param filename Only file names without prepended path allowed.
+ * @return pointer to extension
+ */
+char *get_filename_ext(const char *filename);
+
+/**
+ * Extract the base name of given file name (without the extension).
+ * @param abs_file_name Absolute path to file name.
+ * @param base_name Base name it is extracted to.
+ * @param base_name_length Base name length.
+ * @return indicating success
+ */
+bool dlt_extract_base_name_without_ext(const char* const abs_file_name, char* base_name, long base_name_len);
+
+/**
+ * Initialize (external) logging facility
+ * @param mode DltLoggingMode, 0 = log to stdout, 1 = log to syslog, 2 = log to file, 3 = log to stderr
+ * @param enable_multiple_logfiles, true if multiple logfiles (incl. size limits) should be use
+ * @param logging_file_size, maximum size in bytes of one logging file
+ * @param logging_files_max_size, maximum size in bytes of all logging files
+ */
+DltReturnValue dlt_log_init_multiple_logfiles_support(DltLoggingMode mode, bool enable_multiple_logfiles, int logging_file_size, int logging_files_max_size);
+
+/**
+ * Initialize (external) logging facility for single logfile.
+ */
+DltReturnValue dlt_log_init_single_logfile();
+
+/**
+ * Initialize (external) logging facility for multiple files logging.
+ */
+DltReturnValue dlt_log_init_multiple_logfiles(int logging_file_size, int logging_files_max_size);
+
+/**
+ * Logs into log files represented by the multiple files buffer.
+ * @param format First element in a specific format that will be logged.
+ * @param ... Further elements in a specific format that will be logged.
+ */
+void dlt_log_multiple_files_write(const char* format, ...);
+
+void dlt_log_free_single_logfile();
+
+void dlt_log_free_multiple_logfiles();
+
+/**
+ * Checks whether (internal) logging in multiple files is active.
+ */
+bool dlt_is_log_in_multiple_files_active();
+
# ifdef __cplusplus
}
# endif