Linux 调试打印时间和颜色

时间:2021-09-07 14:30:19

Linux调试打印时间和颜色

#include <sys/time.h>
#include <unistd.h> void print_time(void)
{ struct timeval tus;
struct tm *ptm;
long ts; ts = time(NULL);
ptm = localtime(&ts);
gettimeofday( &tus, NULL );
printf("[%d.%03d]", ptm->tm_year+1900,tus.tv_usec/1000); }