- if (inlog)
- return;
- inlog = 1;
-
- /* Initialise the Messages */
- va_start(args, message);
- len = vsnprintf(temp_buffer, MAXLOGSIZE - 1, message, args);
- va_end(args);
-
- /* Append \n */
- if (len >= MAXLOGSIZE)
- /* vsnprintf hit the buffer size*/
- temp_buffer[MAXLOGSIZE-2] = '\n';
- else {
- temp_buffer[len] = '\n';
- temp_buffer[len+1] = 0;
- }
-
- generate_message_details(log_details_buffer, sizeof(log_details_buffer),
- file_configs[logtype].set ?
- file_configs[logtype].display_options :
- file_configs[logtype_default].display_options,
- loglevel, logtype);
-
- /* Check if requested logtype is setup */
- if (file_configs[logtype].set)
- /* Yes */
- fd = file_configs[logtype].fd;
- else
- /* No: use default */
- fd = file_configs[logtype_default].fd;
-
- /* If default wasnt setup its fd is -1 */
- if (fd >= 0) {
- iov[0].iov_base = log_details_buffer;
- iov[0].iov_len = strlen(log_details_buffer);
- iov[1].iov_base = temp_buffer;
- iov[1].iov_len = strlen(temp_buffer);
- writev( fd, iov, 2);
- }
-
- inlog = 0;
+ if (inlog)
+ return;
+
+ /* Check if requested logtype is setup */
+ if (file_configs[logtype].set)
+ /* Yes */
+ fd = file_configs[logtype].fd;
+ else
+ /* No: use default */
+ fd = file_configs[logtype_default].fd;
+
+ if (fd < 0) {
+ /* no where to send the output, give up */
+ return;
+ }
+
+ inlog = 1;
+ /* Initialise the Messages */
+ va_start(args, message);
+ len = vsnprintf(temp_buffer, MAXLOGSIZE -1, message, args);
+ va_end(args);
+
+ /* Append \n */
+ if (len ==-1 || len >= MAXLOGSIZE -1) {
+ /* vsnprintf hit the buffer size*/
+ temp_buffer[MAXLOGSIZE-2] = '\n';
+ temp_buffer[MAXLOGSIZE-1] = 0;
+ }
+ else {
+ temp_buffer[len] = '\n';
+ temp_buffer[len+1] = 0;
+ }
+
+ generate_message_details(log_details_buffer, sizeof(log_details_buffer),
+ file_configs[logtype].set ?
+ file_configs[logtype].display_options :
+ file_configs[logtype_default].display_options,
+ loglevel, logtype);
+
+
+ /* If default wasnt setup its fd is -1 */
+ iov[0].iov_base = log_details_buffer;
+ iov[0].iov_len = strlen(log_details_buffer);
+ iov[1].iov_base = temp_buffer;
+ iov[1].iov_len = strlen(temp_buffer);
+ writev( fd, iov, 2);
+
+ inlog = 0;