diff options
| author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2026-05-12 13:34:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-12 13:34:13 -0400 |
| commit | d8ee8c27444a56bb98dd8bd67a019a1e9efbcc10 (patch) | |
| tree | 6ae1275a5f8e5794b917aac95c6cb1ab3f4cb6c5 /src/lib/core/log.c | |
| parent | 4649a889a916aa377ebd3ca8f3daa9ac703baa34 (diff) | |
| parent | 1d91efc28e30c8501428fec8ff6cd7b13dcdfb95 (diff) | |
| download | stasis-master.tar.gz | |
Bughunt 0x1002
Diffstat (limited to 'src/lib/core/log.c')
| -rw-r--r-- | src/lib/core/log.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/lib/core/log.c b/src/lib/core/log.c index aea3231..b1cab4c 100644 --- a/src/lib/core/log.c +++ b/src/lib/core/log.c @@ -42,19 +42,38 @@ void log_print_debug(const struct ExecPoint ep, const char *fmt, ...) { int log_msgv(FILE *stream, const struct ExecPoint ep, const char *preface_color, const char *preface, const char *fmt, va_list ap) { char header[STASIS_BUFSIZ] = {0}; + const int no_info = LOG_LEVEL < LOG_LEVEL_INFO; + const int some_info = LOG_LEVEL < LOG_LEVEL_DEBUG; int len = snprintf(header, sizeof(header), STASIS_COLOR_RESET "%s%s: " - STASIS_COLOR_RESET - STASIS_COLOR_WHITE - "%s:%d: %s(): " STASIS_COLOR_RESET, preface_color ? preface_color : STASIS_COLOR_RED, - preface ? preface : "UNKNOWN", - path_basename((char *) ep.file), - ep.line, - ep.function); + preface ? preface : "UNKNOWN"); + + if (no_info) { + len += snprintf(header + strlen(header), sizeof(header) - len, + STASIS_COLOR_WHITE + "" + STASIS_COLOR_RESET); + } else if (some_info) { + len += snprintf(header + strlen(header), sizeof(header) - len, + STASIS_COLOR_WHITE + "%s(): " + STASIS_COLOR_RESET, + ep.function); + } else { + // everything + len += snprintf(header + strlen(header), sizeof(header) - len, + STASIS_COLOR_WHITE + "%s:%d: %s(): " + STASIS_COLOR_RESET, + path_basename((char *) ep.file), + ep.line, + ep.function); + } + if (len >= (int) sizeof(header)) { SYSERROR("header format truncated (%d >= %d)", len, (int) sizeof(header)); return len; |
