From 0cfa46fe374ae19e0eb0f67eb1a444b03ff41e37 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Sun, 9 Sep 2012 21:50:56 +0000 Subject: [PATCH] added --sensor-log-interval option --- NEWS | 2 +- src/server/server.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 078fdf5..4581b06 100644 --- a/NEWS +++ b/NEWS @@ -2,12 +2,12 @@ ** added Spanish translation from LP (Javier buik8roadmaster@hotmail.com). -** psensor-server: added sensors log file (--sensor-log-file). ** psensor: fixed 'appindicator enabled' option not working correctly for cpu usage. The option was inversed each time it is displayed in the preference dialog. ** psensor: added an option to enable logging of sensors ($HOME/.psensor/sensors.log). +** psensor-server: added sensors logging (--sensor-log-file). * v0.7.0.3 diff --git a/src/server/server.c b/src/server/server.c index 8ed87e8..c00ebfb 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -67,6 +67,7 @@ static struct option long_options[] = { {"debug", required_argument, 0, 'd'}, {"log-file", required_argument, 0, 'l'}, {"sensor-log-file", required_argument, 0, 0}, + {"sensor-log-interval", required_argument, 0, 0}, {0, 0, 0, 0} }; @@ -108,6 +109,8 @@ static void print_help() "set the debug level, integer between 0 and 3")); puts(_(" -l, --log-file=PATH set the log file to PATH")); puts(_(" --sensor-log-file=PATH set the sensor log file to PATH")); + puts(_(" --sensor-log-interval=S " + "set the sensor log interval to S (seconds)")); puts(""); printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT); @@ -309,7 +312,7 @@ static int cbk_http_request(void *cls, int main(int argc, char *argv[]) { struct MHD_Daemon *d; - int port, opti, optc, cmdok, ret; + int port, opti, optc, cmdok, ret, slog_interval; char *log_file, *slog_file; program_name = argv[0]; @@ -325,6 +328,7 @@ int main(int argc, char *argv[]) server_data.psysinfo.interfaces = NULL; log_file = NULL; slog_file = NULL; + slog_interval = 300; port = DEFAULT_PORT; cmdok = 1; @@ -359,6 +363,9 @@ int main(int argc, char *argv[]) case 0: if (!strcmp(long_options[opti].name, "sensor-log-file")) slog_file = strdup(optarg); + else if (!strcmp(long_options[opti].name, + "sensor-log-interval")) + slog_interval = atoi(optarg); break; default: cmdok = 0; @@ -405,7 +412,12 @@ int main(int argc, char *argv[]) log_info(_("URL: http://localhost:%d"), port); if (slog_file) { - ret = slog_activate(slog_file, server_data.sensors, &mutex, 5); + if (slog_interval <= 0) + slog_interval = 300; + ret = slog_activate(slog_file, + server_data.sensors, + &mutex, + slog_interval); if (!ret) log_err(_("Failed to activate logging of sensors.")); } -- 2.7.4