X-Git-Url: http://git.wpitchoune.net/gitweb/?p=psensor-pkg-ubuntu.git;a=blobdiff_plain;f=src%2Flib%2Fslog.c;h=15ccd0b8ddd8b2e854c47095cc9d39b3cdc48013;hp=d3e646db778dc90c2aaeeb3ac517dad4d9c7f782;hb=4c01ba89aac969b4c19190dd8f27329b5dd24a6e;hpb=2e68c12dc10ca8c06b03aad6b4e44144a9134cd5 diff --git a/src/lib/slog.c b/src/lib/slog.c index d3e646d..15ccd0b 100644 --- a/src/lib/slog.c +++ b/src/lib/slog.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2013 jeanfi@gmail.com + * Copyright (C) 2010-2014 jeanfi@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -33,7 +33,8 @@ #include "bool.h" #include "config.h" -#include "log.h" +#include +#include #include "ptime.h" #include "slog.h" @@ -47,6 +48,24 @@ static time_t st; static const char *DEFAULT_FILENAME = "sensors.log"; +static char *time_to_str(time_t *t) +{ + struct tm lt; + char *str; + + if (!localtime_r(t, <)) + return NULL; + + str = malloc(64); + + if (strftime(str, 64, "%s", <)) { + return str; + } else { + free(str); + return NULL; + } +} + static char *get_default_path() { char *home, *path, *dir; @@ -115,7 +134,7 @@ static void slog_write_sensors(struct psensor **sensors) bool first_call; if (!file) { - log_err(_("Sensor log file not open.")); + log_debug(_("Sensor log file not open.")); return ; } @@ -151,9 +170,9 @@ static void *slog_routine(void *data) { while (1) { pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); - pthread_mutex_lock(sensors_mutex); + pmutex_lock(sensors_mutex); slog_write_sensors(sensors); - pthread_mutex_unlock(sensors_mutex); + pmutex_unlock(sensors_mutex); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); sleep(period); }