Created
August 2, 2016 02:47
-
-
Save luoyetx/e36514b80a9951b43e06ece6b2cf57e5 to your computer and use it in GitHub Desktop.
logging
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 <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