How do I add timestamp to the log file in ubuntu? I have the following code in my c file:
#define LOG_MSG(args, ...) fprintf(log_file, "%-*d" args " \n", 5,line_count++, ##__VA_ARGS__);
#define LOG_ERR(args, ...) do {fprintf(log_file, "%-*d%s" args " \n",5, line_count++, "Error: ", ##__VA_ARGS__); increment_error_count();} while(0)
I tried including `date +%H:%M:%S in the above code, but it throws an error - undefined Any help is appreciated :) Thanks in advance.