diff options
Diffstat (limited to 'logger.c')
-rw-r--r-- | logger.c | 38 |
1 files changed, 26 insertions, 12 deletions
@@ -21,14 +21,21 @@ void logger_none(char *format,...) { } void logger_stdout(char *format,...) { va_list args; - struct timeval unixtime; - struct tm *time; + struct timeval systime; + struct tm *systime_tm; char timestring[255]; + time_t unixtime; - gettimeofday(&unixtime,NULL); - time=localtime(&unixtime.tv_sec); - strftime(timestring,255,"%F %T",time); - printf("%s: ",timestring); + if (config.use_unixtime==0) + { + gettimeofday(&systime,NULL); + systime_tm=localtime(&systime.tv_sec); + strftime(timestring,sizeof(timestring),"%F %T",systime_tm); + printf("%s: ",timestring); + } else { + unixtime=time(NULL); + printf("%ld: ",unixtime); + } va_start(args,format); vprintf(format,args); @@ -109,17 +116,24 @@ void csvlog_init() // Write a single line of CSV data void csvlog_write() { - struct timeval unixtime; - struct tm *time; + struct timeval systime; + struct tm *systime_tm; char timestring[255]; + time_t unixtime; DEBUG1_LOG("Writing data series to CSV file\n"); - gettimeofday(&unixtime,NULL); - time=localtime(&unixtime.tv_sec); - strftime(timestring,255,"%F %T",time); + if (config.use_unixtime==0) + { + gettimeofday(&systime,NULL); + systime_tm=localtime(&systime.tv_sec); + strftime(timestring,sizeof(timestring),"\"%F %T\"",systime_tm); + } else { + unixtime=time(NULL); + snprintf(timestring,sizeof(timestring),"%ld",unixtime); + } - fprintf(config.csvfile,"\"%s\",\"%ld\",\"%ld\",\"%ld\",\"%ld\",\"%ld\",\"%ld\"\n",timestring,cpudata.min_freq,cpudata.max_freq,cpudata.cur_freq,cpudata.cur_temp/1000,config.max_temp/1000,cpudata.scale_max); + fprintf(config.csvfile,"%s,\"%ld\",\"%ld\",\"%ld\",\"%ld\",\"%ld\",\"%ld\"\n",timestring,cpudata.min_freq,cpudata.max_freq,cpudata.cur_freq,cpudata.cur_temp/1000,config.max_temp/1000,cpudata.scale_max); } // Close the CSV file |