summaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
authorSaya Sugiura <ssugiura@jp.adit-jv.com>2019-05-29 17:58:37 +0900
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2019-06-19 11:00:37 +0900
commit9cf8c10a22542ce784c383d7e371797c4b9910ac (patch)
treeb43fb9e5692e8354dc203fc382c3263d7876ad40 /src/daemon
parent6088448cdfe3cd152c53136544acc4ee7a508a84 (diff)
downloadDLT-daemon-9cf8c10a22542ce784c383d7e371797c4b9910ac.tar.gz
cleanup: Use dlt_vlog()
There were a couple of places which used snprintf-dlt_log. It is now replaced with dlt_vlog(). Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/dlt-daemon.c184
-rw-r--r--src/daemon/dlt_daemon_client.c68
-rw-r--r--src/daemon/dlt_daemon_common.c18
-rw-r--r--src/daemon/dlt_daemon_connection.c7
-rw-r--r--src/daemon/dlt_daemon_event_handler.c11
-rw-r--r--src/daemon/dlt_daemon_socket.c14
6 files changed, 79 insertions, 223 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index b4c82b0..9144b2a 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -76,9 +76,6 @@
\{
*/
-/** Global text output buffer, mainly used for creation of error/warning strings */
-static char str[DLT_DAEMON_TEXTBUFSIZE];
-
static int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose);
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
@@ -632,6 +629,7 @@ static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
int main(int argc, char *argv[])
{
char version[DLT_DAEMON_TEXTBUFSIZE];
+ char local_str[DLT_DAEMON_TEXTBUFSIZE];
DltDaemonLocal daemon_local;
DltDaemon daemon;
int back = 0;
@@ -663,8 +661,7 @@ int main(int argc, char *argv[])
/* Print version information */
dlt_get_version(version, DLT_DAEMON_TEXTBUFSIZE);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Starting DLT Daemon; %s\n", version);
- dlt_log(LOG_NOTICE, str);
+ dlt_vlog(LOG_NOTICE, "Starting DLT Daemon; %s\n", version);
PRINT_FUNCTION_VERBOSE(daemon_local.flags.vflag);
@@ -672,8 +669,7 @@ int main(int argc, char *argv[])
/* Make sure the parent user directory is created */
if (dlt_mkdir_recursive(dltFifoBaseDir) != 0) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Base dir %s cannot be created!\n", dltFifoBaseDir);
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", dltFifoBaseDir);
return -1;
}
@@ -789,9 +785,11 @@ int main(int argc, char *argv[])
&daemon,
&daemon_local);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Exiting DLT daemon... [%d]", g_signo);
- dlt_daemon_log_internal(&daemon, &daemon_local, str, daemon_local.flags.vflag);
- dlt_log(LOG_NOTICE, str);
+ snprintf(local_str, DLT_DAEMON_TEXTBUFSIZE, "Exiting DLT daemon... [%d]",
+ g_signo);
+ dlt_daemon_log_internal(&daemon, &daemon_local, local_str,
+ daemon_local.flags.vflag);
+ dlt_log(LOG_NOTICE, local_str);
dlt_daemon_local_cleanup(&daemon, &daemon_local, daemon_local.flags.vflag);
@@ -974,11 +972,8 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
fd = open(daemon_local->flags.yvalue, O_RDWR);
if (fd < 0) {
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Failed to open serial device %s\n",
+ dlt_vlog(LOG_ERR, "Failed to open serial device %s\n",
daemon_local->flags.yvalue);
- dlt_log(LOG_ERR, str);
daemon_local->flags.yvalue[0] = 0;
return -1;
@@ -996,12 +991,8 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
close(fd);
daemon_local->flags.yvalue[0] = 0;
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Failed to configure serial device %s (%s) \n",
- daemon_local->flags.yvalue,
- strerror(errno));
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "Failed to configure serial device %s (%s) \n",
+ daemon_local->flags.yvalue, strerror(errno));
return -1;
}
@@ -1032,7 +1023,6 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
int ret;
int fd = -1;
int fifo_size;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
/* open named pipe(FIFO) to receive DLT messages from users */
umask(0);
@@ -1044,43 +1034,32 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
ret = mkfifo(tmpFifo, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret == -1) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "FIFO user %s cannot be created (%s)!\n",
- tmpFifo,
- strerror(errno));
- dlt_log(LOG_WARNING, local_str);
+ dlt_vlog(LOG_WARNING, "FIFO user %s cannot be created (%s)!\n",
+ tmpFifo, strerror(errno));
return -1;
} /* if */
fd = open(tmpFifo, O_RDWR);
if (fd == -1) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "FIFO user %s cannot be opened (%s)!\n",
- tmpFifo,
- strerror(errno));
- dlt_log(LOG_WARNING, local_str);
+ dlt_vlog(LOG_WARNING, "FIFO user %s cannot be opened (%s)!\n",
+ tmpFifo, strerror(errno));
return -1;
} /* if */
if (daemon_local->daemonFifoSize != 0) {
/* Set Daemon FIFO size */
if (fcntl(fd, F_SETPIPE_SZ, daemon_local->daemonFifoSize) == -1) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "set FIFO size error: %s\n", strerror(errno));
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "set FIFO size error: %s\n", strerror(errno));
}
}
/* Get Daemon FIFO size */
if ((fifo_size = fcntl(fd, F_GETPIPE_SZ, 0)) == -1) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "get FIFO size error: %s\n", strerror(errno));
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "get FIFO size error: %s\n", strerror(errno));
}
else {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "FIFO size: %d\n", fifo_size);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "FIFO size: %d\n", fifo_size);
}
/* Early init, to be able to catch client (app) connections
@@ -1099,19 +1078,13 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
int fd = -1;
int mask = 0;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: Invalid function parameters\n",
- __func__);
-
- dlt_log(LOG_ERR, local_str);
+ dlt_vlog(LOG_ERR, "%s: Invalid function parameters\n", __func__);
return -1;
}
@@ -1499,8 +1472,8 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
/* check if overflow occurred */
if (daemon->overflow_counter) {
if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) {
- sprintf(str, "%u messages discarded!\n", daemon->overflow_counter);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "%u messages discarded!\n",
+ daemon->overflow_counter);
daemon->overflow_counter = 0;
}
}
@@ -1603,12 +1576,9 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
daemon_local->flags.vflag);
}
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
+ dlt_vlog(LOG_DEBUG,
"New client connection #%d established, Total Clients : %d\n",
- in_sock,
- daemon_local->client_connections);
- dlt_log(LOG_DEBUG, local_str);
+ in_sock, daemon_local->client_connections);
dlt_daemon_log_internal(daemon, daemon_local, local_str, daemon_local->flags.vflag);
if (daemon_local->client_connections == 1) {
@@ -1820,9 +1790,7 @@ int dlt_daemon_process_control_connect(
}
if (verbose) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE,
- "New connection to control client established\n");
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "New connection to control client established\n");
}
return 0;
@@ -1872,9 +1840,7 @@ int dlt_daemon_process_app_connect(
}
if (verbose) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE,
- "New connection to application established\n");
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "New connection to application established\n");
}
return 0;
@@ -1954,18 +1920,14 @@ static int dlt_daemon_process_user_message_not_sup(DltDaemon *daemon,
DltReceiver *receiver,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
DltUserHeader *userheader = (DltUserHeader *)(receiver->buf);
(void)daemon;
(void)daemon_local;
PRINT_FUNCTION_VERBOSE(verbose);
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid user message type received: %d!\n",
+ dlt_vlog(LOG_ERR, "Invalid user message type received: %d!\n",
userheader->message);
- dlt_log(LOG_ERR, local_str);
/* remove user header */
if (dlt_receiver_remove(receiver, sizeof(DltUserHeader)) == -1)
@@ -2091,18 +2053,13 @@ int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
int verbose)
{
uint32_t len = sizeof(DltUserControlMsgBufferOverflow);
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
DltUserControlMsgBufferOverflow userpayload;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
@@ -2158,7 +2115,6 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
DltDaemonApplication *application = NULL;
DltDaemonApplication *old_application = NULL;
pid_t old_pid = 0;
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
char description[DLT_DAEMON_DESCSIZE + 1] = { '\0' };
DltUserControlMsgRegisterApplication userapp;
char *origin;
@@ -2166,12 +2122,8 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
@@ -2236,15 +2188,13 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
dlt_daemon_user_send_log_state(daemon, application, verbose);
if (application == NULL) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Can't add ApplicationID '%.4s' for PID %d\n",
- userapp.apid,
- userapp.pid);
- dlt_log(LOG_WARNING, local_str);
+ dlt_vlog(LOG_WARNING, "Can't add ApplicationID '%.4s' for PID %d\n",
+ userapp.apid, userapp.pid);
return -1;
}
else if (old_pid != application->pid) {
+ char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"ApplicationID '%.4s' registered for PID %d, Description=%s\n",
@@ -2266,7 +2216,6 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
int to_remove = 0;
uint32_t len = sizeof(DltUserControlMsgRegisterContext);
DltUserControlMsgRegisterContext userctxt;
@@ -2281,12 +2230,8 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
@@ -2380,16 +2325,14 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
verbose);
if (context == 0) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
+ dlt_vlog(LOG_WARNING,
"Can't add ContextID '%.4s' for ApID '%.4s'\n in %s",
- userctxt.ctid,
- userctxt.apid,
- __func__);
- dlt_log(LOG_WARNING, local_str);
+ userctxt.ctid, userctxt.apid, __func__);
return -1;
}
else {
+ char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"ContextID '%.4s' registered for ApID '%.4s', Description=%s\n",
@@ -2474,7 +2417,6 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
{
uint32_t len = sizeof(DltUserControlMsgUnregisterApplication);
DltUserControlMsgUnregisterApplication userapp;
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
DltDaemonApplication *application = NULL;
DltDaemonContext *context;
int i, offset_base;
@@ -2548,6 +2490,8 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
return -1;
}
else {
+ char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Unregistered ApID '%.4s'\n",
@@ -2569,7 +2513,6 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
uint32_t len = sizeof(DltUserControlMsgUnregisterContext);
DltUserControlMsgUnregisterContext userctxt;
DltDaemonContext *context;
@@ -2612,6 +2555,8 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
return -1;
}
else {
+ char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Unregistered CtID '%.4s' for ApID '%.4s'\n",
@@ -2728,8 +2673,8 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
/* check if overflow occurred */
if (daemon->overflow_counter) {
if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%u messages discarded!\n", daemon->overflow_counter);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "%u messages discarded!\n",
+ daemon->overflow_counter);
daemon->overflow_counter = 0;
}
}
@@ -2768,7 +2713,6 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
int sent;
uint8_t *rcv_buffer = NULL;
int size;
@@ -2780,25 +2724,16 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
rcv_buffer = calloc(1, DLT_SHM_RCV_BUFFER_SIZE);
if (!rcv_buffer) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "No memory to allocate receiver buffer in %s.\n",
+ dlt_vlog(LOG_ERR, "No memory to allocate receiver buffer in %s.\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
-
return -1;
}
@@ -3020,18 +2955,13 @@ int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
uint32_t len = sizeof(DltUserControlMsgLogMode);
DltUserControlMsgLogMode userctxt;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
@@ -3162,12 +3092,8 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
local_fd = timerfd_create(CLOCK_MONOTONIC, 0);
if (local_fd < 0) {
- snprintf(str,
- sizeof(str),
- "<%s> timerfd_create failed: %s\n",
- timer_name,
- strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "<%s> timerfd_create failed: %s\n",
+ timer_name, strerror(errno));
}
l_timer_spec.it_interval.tv_sec = period_sec;
@@ -3176,12 +3102,8 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
l_timer_spec.it_value.tv_nsec = 0;
if (timerfd_settime(local_fd, 0, &l_timer_spec, NULL) < 0) {
- snprintf(str,
- sizeof(str),
- "<%s> timerfd_settime failed: %s\n",
- timer_name,
- strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "<%s> timerfd_settime failed: %s\n",
+ timer_name, strerror(errno));
local_fd = -1;
}
}
@@ -3191,12 +3113,8 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
* Event handling registration is done later on with other connections.
*/
if (local_fd > 0) {
- snprintf(str,
- sizeof(str),
- "<%s> initialized with %d timer\n",
- timer_name,
+ dlt_vlog(LOG_INFO, "<%s> initialized with %d timer\n", timer_name,
period_sec);
- dlt_log(LOG_INFO, str);
}
return dlt_connection_create(daemon_local,
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c
index e2a0d12..4565322 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -69,9 +69,6 @@
#include "dlt_daemon_offline_logstorage.h"
#include "dlt_gateway.h"
-/** Global text output buffer, mainly used for creation of error/warning strings */
-static char str[DLT_DAEMON_TEXTBUFSIZE];
-
/** Inline function to calculate/set the requested log level or traces status
* with default log level or trace status when "ForceContextLogLevelAndTraceStatus"
* is enabled and set to 1 in dlt.conf file.
@@ -180,14 +177,9 @@ int dlt_daemon_client_send_all(DltDaemon *daemon,
void *msg1, *msg2;
int msg1_sz, msg2_sz;
int ret = 0;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
if ((daemon == NULL) || (daemon_local == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: Invalid parameters\n",
- __func__);
- dlt_log(LOG_ERR, local_str);
+ dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return 0;
}
@@ -1011,8 +1003,7 @@ void dlt_daemon_control_get_log_info(int sock,
offset += sizeof(uint16_t);
#if (DLT_DEBUG_GETLOGINFO == 1)
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "#apid: %d \n", count_app_ids);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "#apid: %d \n", count_app_ids);
#endif
for (i = 0; i < count_app_ids; i++) {
@@ -1044,8 +1035,7 @@ void dlt_daemon_control_get_log_info(int sock,
#if (DLT_DEBUG_GETLOGINFO == 1)
dlt_print_id(buf, apid);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "apid: %s\n", buf);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "apid: %s\n", buf);
#endif
if (req->apid[0] != '\0')
@@ -1057,14 +1047,12 @@ void dlt_daemon_control_get_log_info(int sock,
offset += sizeof(uint16_t);
#if (DLT_DEBUG_GETLOGINFO == 1)
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "#ctid: %d \n", count_con_ids);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "#ctid: %d \n", count_con_ids);
#endif
for (j = 0; j < count_con_ids; j++) {
#if (DLT_DEBUG_GETLOGINFO == 1)
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "j: %d \n", j);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "j: %d \n", j);
#endif
if (!((count_con_ids == 1) && (req->apid[0] != '\0') &&
@@ -1083,8 +1071,7 @@ void dlt_daemon_control_get_log_info(int sock,
#if (DLT_DEBUG_GETLOGINFO == 1)
dlt_print_id(buf, context->ctid);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "ctid: %s \n", buf);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "ctid: %s \n", buf);
#endif
/* Mode 4, 6, 7 */
@@ -1119,8 +1106,8 @@ void dlt_daemon_control_get_log_info(int sock,
}
#if (DLT_DEBUG_GETLOGINFO == 1)
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "ll=%d ts=%d \n", (int32_t)ll, (int32_t)ts);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "ll=%d ts=%d \n", (int32_t)ll,
+ (int32_t)ts);
#endif
}
@@ -2203,26 +2190,19 @@ int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
{
uint64_t expir = 0;
ssize_t res = 0;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: invalid parameters",
- __func__);
- dlt_log(LOG_ERR, local_str);
+ dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
return -1;
}
res = read(receiver->fd, &expir, sizeof(expir));
if (res < 0) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: Fail to read timer (%s)\n", __func__, strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "%s: Fail to read timer (%s)\n", __func__,
+ strerror(errno));
/* Activity received on timer_wd, but unable to read the fd:
* let's go on sending notification */
}
@@ -2255,26 +2235,19 @@ int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon,
{
uint64_t expir = 0;
ssize_t res = 0;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: invalid parameters",
- __func__);
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
return -1;
}
res = read(receiver->fd, &expir, sizeof(expir));
if (res < 0) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: Fail to read timer (%s)\n", __func__, strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "%s: Fail to read timer (%s)\n", __func__,
+ strerror(errno));
/* Activity received on timer_wd, but unable to read the fd:
* let's go on sending notification */
}
@@ -2313,27 +2286,18 @@ int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
{
uint64_t expir = 0;
ssize_t res = -1;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: invalid parameters",
- __func__);
- dlt_log(LOG_ERR, local_str);
+ dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
return res;
}
res = read(receiver->fd, &expir, sizeof(expir));
if (res < 0) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Failed to read timer_wd; %s\n",
- strerror(errno));
- dlt_log(LOG_WARNING, local_str);
+ dlt_vlog(LOG_WARNING, "Failed to read timer_wd; %s\n", strerror(errno));
/* Activity received on timer_wd, but unable to read the fd:
* let's go on sending notification */
}
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index 4a39d64..cb392dc 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -88,7 +88,6 @@
#include "dlt_daemon_socket.h"
#include "dlt_daemon_serial.h"
-static char str[DLT_DAEMON_COMMON_TEXTBUFSIZE];
char *app_recv_buffer = NULL; /* pointer to receiver buffer for application msges */
sem_t dlt_daemon_mutex;
@@ -240,13 +239,8 @@ int dlt_daemon_init(DltDaemon *daemon,
dlt_set_id(daemon->ecuid, "");
/* initialize ring buffer for client connection */
- snprintf(str,
- DLT_DAEMON_COMMON_TEXTBUFSIZE,
- "Ringbuffer configuration: %lu/%lu/%lu\n",
- RingbufferMinSize,
- RingbufferMaxSize,
- RingbufferStepSize);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "Ringbuffer configuration: %lu/%lu/%lu\n",
+ RingbufferMinSize, RingbufferMaxSize, RingbufferStepSize);
if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize, RingbufferMaxSize,
RingbufferStepSize) == DLT_RETURN_ERROR)
@@ -1312,12 +1306,12 @@ int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int v
/* parse arguments here */
if (strcmp(token, "LoggingMode") == 0) {
daemon->mode = atoi(value);
- snprintf(str, DLT_DAEMON_COMMON_TEXTBUFSIZE, "Runtime Option: %s=%d\n", token, daemon->mode);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "Runtime Option: %s=%d\n", token,
+ daemon->mode);
}
else {
- snprintf(str, DLT_DAEMON_COMMON_TEXTBUFSIZE, "Unknown option: %s=%s\n", token, value);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "Unknown option: %s=%s\n", token,
+ value);
}
}
}
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c
index b1a4080..7973b9c 100644
--- a/src/daemon/dlt_daemon_connection.c
+++ b/src/daemon/dlt_daemon_connection.c
@@ -390,13 +390,8 @@ int dlt_connection_create(DltDaemonLocal *daemon_local,
temp->receiver = dlt_connection_get_receiver(daemon_local, type, fd);
if (!temp->receiver) {
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Unable to get receiver from %d connection.\n",
+ dlt_vlog(LOG_CRIT, "Unable to get receiver from %d connection.\n",
type);
-
- dlt_log(LOG_CRIT, local_str);
free(temp);
return -1;
}
diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c
index 38aa022..b2af56b 100644
--- a/src/daemon/dlt_daemon_event_handler.c
+++ b/src/daemon/dlt_daemon_event_handler.c
@@ -187,7 +187,6 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
{
int ret = 0;
unsigned int i = 0;
- char str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
int (*callback)(DltDaemon *, DltDaemonLocal *, DltReceiver *, int) = NULL;
if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL))
@@ -249,11 +248,8 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
callback = dlt_connection_get_callback(con);
if (!callback) {
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Unable to find function for %d handle type.\n",
+ dlt_vlog(LOG_CRIT, "Unable to find function for %d handle type.\n",
type);
- dlt_log(LOG_CRIT, str);
return -1;
}
@@ -262,11 +258,8 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
daemon_local,
con->receiver,
daemon_local->flags.vflag) == -1) {
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Processing from %d handle type failed!\n",
+ dlt_vlog(LOG_CRIT, "Processing from %d handle type failed!\n",
type);
- dlt_log(LOG_CRIT, str);
return -1;
}
}
diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c
index f9c4ab2..addd3ce 100644
--- a/src/daemon/dlt_daemon_socket.c
+++ b/src/daemon/dlt_daemon_socket.c
@@ -59,9 +59,6 @@
#include "dlt_daemon_socket.h"
-/** Global text output buffer, mainly used for creation of error/warning strings */
-static char str[DLT_DAEMON_TEXTBUFSIZE];
-
int dlt_daemon_socket_open(int *sock, unsigned int servPort)
{
int yes = 1;
@@ -92,9 +89,8 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
continue;
}
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%s: Socket created - socket_family:%i, socket_type:%i, protocol:%i\n",
+ dlt_vlog(LOG_INFO, "%s: Socket created - socket_family:%i, socket_type:%i, protocol:%i\n",
__FUNCTION__, p->ai_family, p->ai_socktype, p->ai_protocol);
- dlt_log(LOG_INFO, str);
if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
const int lastErrno = errno;
@@ -122,15 +118,11 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
freeaddrinfo(servinfo);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%s: Listening on port: %u\n", __FUNCTION__, servPort);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "%s: Listening on port: %u\n", __func__, servPort);
/* get socket buffer size */
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "dlt_daemon_socket_open: Socket send queue size: %d\n",
+ dlt_vlog(LOG_INFO, "dlt_daemon_socket_open: Socket send queue size: %d\n",
dlt_daemon_socket_get_send_qeue_max_size(*sock));
- dlt_log(LOG_INFO, str);
if (listen(*sock, 3) < 0) {
const int lastErrno = errno;