diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-09-12 09:30:02 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-09-12 09:30:02 +0000 |
| commit | 9c3dd1e1e140ef6ed037baaf49fd4eec0fd65e5b (patch) | |
| tree | 52e749a2df2a6cef42a57723fc224412c39240e6 /src/runtime/c/gu/log.c | |
| parent | 2105188bd0ab85a6388bc18de12e43936f996105 (diff) | |
remove the logging from libgu
Diffstat (limited to 'src/runtime/c/gu/log.c')
| -rw-r--r-- | src/runtime/c/gu/log.c | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/runtime/c/gu/log.c b/src/runtime/c/gu/log.c deleted file mode 100644 index 399646c50..000000000 --- a/src/runtime/c/gu/log.c +++ /dev/null @@ -1,79 +0,0 @@ -#include <gu/defs.h> -#include <gu/log.h> - -#include <stdio.h> -#include <stdlib.h> -#include <stdbool.h> -#include <string.h> - -static int gu_log_depth = 0; - -static bool -gu_log_match(const char* pat, size_t patlen, const char* str) -{ - if (patlen > 0 && pat[patlen-1] == '*') { - return strncmp(pat, str, patlen-1) == 0; - } else if (strlen(str) == patlen) { - return strncmp(pat, str, patlen) == 0; - } - return false; -} - -static bool -gu_log_enabled(const char* func, const char* file) -{ - const char* cfg = getenv("GU_LOG"); - if (cfg == NULL) { - return false; - } - const char* p = cfg; - while (true) { - size_t len = strcspn(p, ","); - if (gu_log_match(p, len, func)) { - return true; - } - if (gu_log_match(p, len, file)) { - return true; - } - if (p[len] == '\0') { - break; - } - p = &p[len + 1]; - } - return false; -} - - -void -gu_log_full_v(GuLogKind kind, const char* func, const char* file, int line, - const char* fmt, va_list args) -{ - (void) (kind && line); - if (!gu_log_enabled(func, file)) { - return; - } - if (kind == GU_LOG_KIND_EXIT) { - gu_log_depth--; - } - if (fmt) { - int indent = gu_min(32 + gu_log_depth, 48); - fprintf(stderr, "%-*s: ", indent, func); - vfprintf(stderr, fmt, args); - fputc('\n', stderr); - fflush(stderr); - } - if (kind == GU_LOG_KIND_ENTER) { - gu_log_depth++; - } -} - -void -gu_log_full(GuLogKind kind, const char* func, const char* file, int line, - const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - gu_log_full_v(kind, func, file, line, fmt, args); - va_end(args); -} - |
