#include #include #include #include #include "log.h" static int save; static time_t now; static struct tm *tm; static char buf[25]; /* strlen("2011-10-08T07:07:09+1111") + 1 */ static va_list ap; static enum loglevel def_loglevel = LOG_DEBUG; void logmsg(enum loglevel level, const char *format,...) { if (def_loglevel < level) { return; } save = errno; time(&now); tm = localtime(&now); strftime(buf, sizeof buf, "%FT%T%z", tm); printf("%s ", buf); va_start(ap, format); vprintf(format, ap); va_end(ap); printf("\n"); errno = save; }