X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Flog%2Flog.c;h=adb207862b1c4a65286f6bb63aaf2b70ed76f99c;hp=a4f5c22adde5ba9f54263237acfe17bea3117852;hb=b0c603d007174e75452c1c14402d62d305da76ab;hpb=b08de841267546726f452c89cc326a493ec6549c diff --git a/lib/log/log.c b/lib/log/log.c index a4f5c22..adb2078 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -1,6 +1,8 @@ #include #include +#include +#include #include "log.h" @@ -9,8 +11,17 @@ static bool debug; static void __log(const char *fmt, va_list ap) { + char hms[20] = {'\0'}; + time_t t; + if (!logf) return; + + /* Add timestamp */ + t = time(NULL); + strftime(hms, sizeof(hms), "%T", localtime(&t)); + fprintf(logf, "[%s] ", hms); + vfprintf(logf, fmt, ap); fflush(logf); } @@ -41,6 +52,11 @@ void __pb_log_init(FILE *fp, bool _debug) debug = _debug; } +void pb_log_set_debug(bool _debug) +{ + debug = _debug; +} + FILE *pb_log_get_stream(void) { static FILE *null_stream;