diff options
author | PA4WDH | 2023-05-24 12:57:25 +0200 |
---|---|---|
committer | PA4WDH | 2023-05-24 12:57:25 +0200 |
commit | 16fb812a46d0e8cde432b58f7dbf6fce147eb89f (patch) | |
tree | 9e019f98e515cb21e6c38ff487a82fe375675991 /cputemp2maxfreq.c | |
parent | Detect program name from argv[0] (diff) | |
download | cputemp2maxfreq-16fb812a46d0e8cde432b58f7dbf6fce147eb89f.tar.gz cputemp2maxfreq-16fb812a46d0e8cde432b58f7dbf6fce147eb89f.tar.bz2 cputemp2maxfreq-16fb812a46d0e8cde432b58f7dbf6fce147eb89f.zip |
Add CSV logging
Diffstat (limited to 'cputemp2maxfreq.c')
-rw-r--r-- | cputemp2maxfreq.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cputemp2maxfreq.c b/cputemp2maxfreq.c index 826655a..556e404 100644 --- a/cputemp2maxfreq.c +++ b/cputemp2maxfreq.c @@ -25,6 +25,9 @@ struct s_config config={ "stdout", // Logger name &logger_stdout, // Logger function 0, // Don't log measurement data + "", // CSV logfile + 0, // Don't overwrite CSV logfile + NULL, // File handler for CSV file }; struct s_cpudata cpudata; @@ -52,6 +55,13 @@ int main(int argc,char **argv) config.logger("Interval: %d",config.interval); config.logger("Logger: %s (%p)",config.logger_name,config.logger); config.logger("Log measurement data: %d",config.log_data); + if (config.csvlog[0]==0) + { + config.logger("CSV Log file: Disabled"); + } else { + config.logger("CSV Log file: %s",config.csvlog); + config.logger("Overwrite CSV log: %d",config.csvoverwrite); + } if ((config.max_temp<VALID_TEMP_MIN) || (config.max_temp>VALID_TEMP_MAX)) { @@ -114,6 +124,9 @@ int main(int argc,char **argv) } } +// Initialise CSV logging + if (config.csvlog[0]!=0) csvlog_init(); + // Set signal handlers signal(SIGTERM,signal_handler); signal(SIGINT,signal_handler); @@ -141,6 +154,7 @@ int main(int argc,char **argv) { config.logger("CPU Temperature: %ld, CPU Frequency: %ld",cpudata.cur_temp/1000,cpudata.cur_freq); } + if (config.csvfile!=NULL) csvlog_write(); // Check if we should increase if ((cpudata.cur_temp<config.max_temp) && (cpudata.scale_max<cpudata.max_freq)) |