Author: mis Date: Sun Jul 8 16:31:17 2007 GMT Module: poldek Tag: HEAD ---- Log message: - new trace*() macros
---- Files affected: poldek/poldek: log.c (1.33 -> 1.34) , log.h (1.26 -> 1.27) ---- Diffs: ================================================================ Index: poldek/poldek/log.c diff -u poldek/poldek/log.c:1.33 poldek/poldek/log.c:1.34 --- poldek/poldek/log.c:1.33 Fri Jul 6 01:19:31 2007 +++ poldek/poldek/log.c Sun Jul 8 18:31:12 2007 @@ -31,6 +31,7 @@ #include "log.h" int poldek_VERBOSE = 0; +int poldek_TRACE = -1; static int default_say_goodbye(const char *msg); int (*poldek_log_say_goodbye)(const char *msg) = default_say_goodbye; @@ -116,8 +117,14 @@ int poldek_set_verbose(int v) { + const char *p; + int vv = poldek_VERBOSE; poldek_VERBOSE = v; + + if ((p = getenv("POLDEK_TRACE")) && *p && *p != '0') + poldek_TRACE = 1; + return vv; } @@ -171,20 +178,29 @@ } /* auto line break for errors and warnings */ - if (!last_endlined && !is_continuation && (pri & (LOGERR|LOGWARN))) { - buf[buf_len++] = '\n'; + + if (pri & LOGTTY) { + if (!last_endlined && !is_continuation && (pri & (LOGERR|LOGWARN))) { + buf[buf_len++] = '\n'; + } + last_endlined = is_endlined; } - - last_endlined = is_endlined; if (indent > 0 && (unsigned)indent < sizeof(buf) - buf_len - 2) { memset(&buf[buf_len], ' ', indent); buf_len += indent; } + buf[buf_len] = '\0'; - +#if 0 /* debug */ + if (pri & LOGTTY) { + char s[256]; + n_snprintf(s, sizeof(s), "l [%s] [%s]", buf, fmt); + vfprintf(stderr, s, args); + } +#endif if (*fmt == '\0') { fmt = buf; ================================================================ Index: poldek/poldek/log.h diff -u poldek/poldek/log.h:1.26 poldek/poldek/log.h:1.27 --- poldek/poldek/log.h:1.26 Sun Jul 1 23:04:26 2007 +++ poldek/poldek/log.h Sun Jul 8 18:31:12 2007 @@ -32,6 +32,7 @@ int poldek_verbose(void); int poldek_set_verbose(int v); extern int poldek_VERBOSE; +extern int poldek_TRACE; typedef void (*poldek_vlog_fn)(void *, int pri, const char *fmt, va_list args); @@ -130,6 +131,19 @@ ((void) ((expr) ? 0 : poldek_log(LOGERR | LOGOPT_N | LOGDIE, fmt, ## args))) void poldek_meminf(int vlevel, const char *fmt, ...); + +# define tracef(indent, fmt, args...) \ + do { \ + if (poldek_TRACE > 0) \ + log_i(LOGINFO|LOGOPT_N, indent, "%s() " fmt, __FUNCTION__, ## args); \ + } while(0) + +# define trace(indent, fmt, args...) \ + do { \ + if (poldek_TRACE > 0) \ + log_i(LOGINFO|LOGOPT_N, indent, fmt, ## args); \ + } while(0) + #if ENABLE_TRACE # define DBGF(fmt, args...) fprintf(stdout, "dbg:%-18s: " fmt, __FUNCTION__ , ## args) ================================================================ ---- CVS-web: http://cvs.pld-linux.org/poldek/poldek/log.c?r1=1.33&r2=1.34&f=u http://cvs.pld-linux.org/poldek/poldek/log.h?r1=1.26&r2=1.27&f=u _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit