dlt_log(LOG_WARNING, "Old message queue exists, trying to delete.\n");
if(mq_unlink(queue_name) < 0)
{
- dlt_log(LOG_CRIT, "Could not delete existing message queue!\n");
- dlt_log(LOG_CRIT, strerror(errno));
+ char str[256];
+ snprintf(str,255,"Could not delete existing message queue!: %s \n",strerror(errno));
+ dlt_log(LOG_CRIT, str);
}
else // Retry
{
}
if(dlt_user.dlt_segmented_queue_read_handle < 0)
{
- dlt_log(LOG_CRIT, "Can't create message queue read handle!\n");
- dlt_log(LOG_CRIT, strerror(errno));
+ char str[256];
+ snprintf(str,255,"Can't create message queue read handle!: %s \n",strerror(errno));
+ dlt_log(LOG_CRIT, str);
pthread_mutex_unlock(&mq_mutex);
return -1;
}
dlt_user.dlt_segmented_queue_write_handle = mq_open(queue_name, O_WRONLY|O_NONBLOCK);
if(dlt_user.dlt_segmented_queue_write_handle < 0)
{
- dlt_log(LOG_CRIT, "Can't open message queue write handle!\n");
- dlt_log(LOG_CRIT, strerror(errno));
+
+ char str[256];
+ snprintf(str,255,"Can't open message queue write handle!: %s \n",strerror(errno));
+ dlt_log(LOG_CRIT, str);
pthread_mutex_unlock(&mq_mutex);
return -1;
}
void dlt_user_atexit_handler(void)
{
+ if (dlt_user_initialised==0)
+ {
+ return;
+ }
/* Try to resend potential log messages in the user buffer */
int count = dlt_user_atexit_blow_out_user_buffer();
if(dlt_user_queue_resend() < 0 && dlt_user.dlt_log_handle >= 0)
{
- dlt_log(LOG_WARNING, "Failed to queue resending.\n");
+ dlt_log(LOG_WARNING, "dlt_forward_msg: Failed to queue resending.\n");
}
}
return -1;
}
- type_info = DLT_TYPE_INFO_STRG;
+ type_info = DLT_TYPE_INFO_STRG | DLT_SCOD_ASCII;
+
+ memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ log->size += sizeof(uint32_t);
+ }
+
+ arg_size = strlen(text) + 1;
+
+ memcpy((log->buffer)+log->size,&(arg_size),sizeof(uint16_t));
+ log->size += sizeof(uint16_t);
+
+ memcpy((log->buffer)+log->size,text,arg_size);
+ log->size += arg_size;
+
+ log->args_num ++;
+
+ return 0;
+}
+
+int dlt_user_log_write_utf8_string(DltContextData *log, const char *text)
+{
+ uint16_t arg_size;
+ uint32_t type_info;
+
+ if ((log==0) || (text==0))
+ {
+ return -1;
+ }
+
+ arg_size = strlen(text)+1;
+
+ if ((log->size+arg_size+sizeof(uint16_t))>DLT_USER_BUF_MAX_SIZE)
+ {
+ return -1;
+ }
+
+ if (dlt_user.verbose_mode)
+ {
+ if ((log->size+arg_size+sizeof(uint32_t)+sizeof(uint16_t))>DLT_USER_BUF_MAX_SIZE)
+ {
+ return -1;
+ }
+
+ type_info = DLT_TYPE_INFO_STRG | DLT_SCOD_UTF8;
memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
log->size += sizeof(uint32_t);
if(read != sizeof(s_segmented_data *))
{
- dlt_log(LOG_ERR, "NWTSegmented: Error while reading queue.\n");
- dlt_log(LOG_ERR, strerror(errno));
+
+ char str[255];
+ snprintf(str,254,"NWTSegmented: Error while reading queue: %s \n",strerror(errno));
+ dlt_log(LOG_CRIT, str);
continue;
}
}
free(thread_data->header);
free(thread_data->payload);
- free(thread_data);
- dlt_log(LOG_ERR, "NWTSegmented: Could not write into queue.\n");
- dlt_log(LOG_ERR, strerror(errno));
+ free(thread_data);
+ char str[256];
+ snprintf(str,255,"NWTSegmented: Could not write into queue: %s \n",strerror(errno));
+ dlt_log(LOG_CRIT, str);
return -1;
}
if(mq_send(dlt_user.dlt_segmented_queue_write_handle, (char *)&resend_data, sizeof(s_segmented_data *), 1) < 0)
{
- dlt_log(LOG_ERR,"Could not request resending.\n");
- dlt_log(LOG_ERR, strerror(errno));
+ char str[255];
+ snprintf(str,254,"Could not request resending.: %s \n",strerror(errno));
+ dlt_log(LOG_CRIT, str);
free(resend_data);
return -1;
}
// Fail silenty if FIFO is not open
if(dlt_user_queue_resend() < 0 && dlt_user.dlt_log_handle >= 0)
{
- dlt_log(LOG_WARNING, "Failed to queue resending.\n");
+ dlt_log(LOG_WARNING, "dlt_user_log_send_log: Failed to queue resending.\n");
}
}
if(dlt_user_queue_resend() < 0 && dlt_user.dlt_log_handle >= 0)
{
- dlt_log(LOG_WARNING, "Failed to queue resending.\n");
+ dlt_log(LOG_WARNING, "dlt_user_log_send_register_application: Failed to queue resending.\n");
}
}
if(dlt_user_queue_resend() < 0 && dlt_user.dlt_log_handle >= 0)
{
- dlt_log(LOG_WARNING, "Failed to queue resending.\n");
+ dlt_log(LOG_WARNING, "dlt_user_log_send_register_context: Failed to queue resending.\n");
}
}