projects
/
psensor-pkg-ubuntu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 1.1.2
[psensor-pkg-ubuntu.git]
/
src
/
lib
/
slog.c
diff --git
a/src/lib/slog.c
b/src/lib/slog.c
index
cb2b124
..
5b16526
100644
(file)
--- a/
src/lib/slog.c
+++ b/
src/lib/slog.c
@@
-33,7
+33,8
@@
#include "bool.h"
#include "config.h"
#include "bool.h"
#include "config.h"
-#include "log.h"
+#include <plog.h>
+#include <pmutex.h>
#include "ptime.h"
#include "slog.h"
#include "ptime.h"
#include "slog.h"
@@
-47,6
+48,23
@@
static time_t st;
static const char *DEFAULT_FILENAME = "sensors.log";
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;
+
+ free(str);
+ return NULL;
+}
+
static char *get_default_path()
{
char *home, *path, *dir;
static char *get_default_path()
{
char *home, *path, *dir;
@@
-64,10
+82,10
@@
static char *get_default_path()
free(dir);
return path;
free(dir);
return path;
- } else {
- log_warn(_("HOME variable not set."));
- return strdup(DEFAULT_FILENAME);
}
}
+
+ log_warn(_("HOME variable not set."));
+ return strdup(DEFAULT_FILENAME);
}
static bool slog_open(const char *path, struct psensor **sensors)
}
static bool slog_open(const char *path, struct psensor **sensors)
@@
-115,8
+133,8
@@
static void slog_write_sensors(struct psensor **sensors)
bool first_call;
if (!file) {
bool first_call;
if (!file) {
- log_
err
(_("Sensor log file not open."));
- return
;
+ log_
debug
(_("Sensor log file not open."));
+ return;
}
gettimeofday(&tv, NULL);
}
gettimeofday(&tv, NULL);
@@
-151,9
+169,9
@@
static void *slog_routine(void *data)
{
while (1) {
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
{
while (1) {
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
- p
thread_
mutex_lock(sensors_mutex);
+ pmutex_lock(sensors_mutex);
slog_write_sensors(sensors);
slog_write_sensors(sensors);
- p
thread_
mutex_unlock(sensors_mutex);
+ pmutex_unlock(sensors_mutex);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
sleep(period);
}
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
sleep(period);
}