Part Number: CC3220SF-LAUNCHXL
Tool/software: Code Composer Studio
I need to print the current date and time (timestamp to a log file).
I have used
#include <time.h>
and here is my logging function:
void EnterLog()
{
//Open the log file
FILE *fp;
fp = fopen (LOGFILE, "a");
if (fp == NULL)
printf ("Error opening file");
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
char *str = asctime(localtime(&rawtime));
strcat(str, " 1 dose was delivered\n");
fprintf(fp,"%s",str);
fclose(fp);
}
When I run my program, the log file has this content:
Thu Jan 1 00:01:11 1970
1 dose was delivered
How do I print the current date and time to the log file?