Skip to content

Instantly share code, notes, and snippets.

@luoyetx
Created August 2, 2016 02:47
Show Gist options
  • Save luoyetx/e36514b80a9951b43e06ece6b2cf57e5 to your computer and use it in GitHub Desktop.
Save luoyetx/e36514b80a9951b43e06ece6b2cf57e5 to your computer and use it in GitHub Desktop.
logging
#include <time.h>
#include <stdio.h>
#include <stdarg.h>
void LOG(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
char msg[256];
vsprintf(msg, fmt, args);
va_end(args);
char buff[256];
time_t t = time(NULL);
strftime(buff, sizeof(buff), "[%x - %X]", localtime(&t));
printf("%s %s\n", buff, msg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment