Skip to content

Commit

Permalink
log: eliminate redundant newlines sometimes present
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Aug 14, 2024
1 parent 60d34fb commit e676d1d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "nng_impl.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef NNG_PLATFORM_WINDOWS
#include <io.h>
Expand Down Expand Up @@ -167,9 +168,11 @@ stderr_logger(nng_log_level level, nng_log_facility facility,

strftime(when, sizeof(when), "%H:%M:%S", tm);
// we print with millisecond resolution
(void) fprintf(stderr, "%s[%-6s]: %s.%03d: %s%s%s%s\n", sgr, level_str,
bool trailing_nl =
((strlen(msg) != 0) && msg[strlen(msg) - 1] == '\n');
(void) fprintf(stderr, "%s[%-6s]: %s.%03d: %s%s%s%s%s", sgr, level_str,
when, nsec / 1000000, msgid ? msgid : "", msgid ? ": " : "", msg,
sgr0);
sgr0, trailing_nl ? "" : "\n");
}

void
Expand Down

0 comments on commit e676d1d

Please sign in to comment.