Skip to content

Instantly share code, notes, and snippets.

@oxUnd
Created July 13, 2014 00:08
Show Gist options
  • Save oxUnd/6633b86e747cb48c3f4e to your computer and use it in GitHub Desktop.
Save oxUnd/6633b86e747cb48c3f4e to your computer and use it in GitHub Desktop.
debug.c
#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