Created
July 13, 2014 00:08
-
-
Save oxUnd/6633b86e747cb48c3f4e to your computer and use it in GitHub Desktop.
debug.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdarg.h> | |
#include <time.h> | |
int debug(const char *rule, ...) { | |
int ret; | |
char *buf; | |
time_t result = time(NULL); | |
va_list ap; | |
va_start(ap, rule); | |
vasprintf(&buf, rule, ap); | |
ret = fprintf(stderr, "[DEBUG] %s -- %s", buf, asctime(localtime(&result))); | |
va_end(ap); | |
return ret; | |
} | |
int main() { | |
debug("%s", "print first"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment