1 --- a/src/rrd_daemon.c 2015-08-09 17:18:19.000000000 +0200
2 +++ b/src/rrd_daemon.c 2015-08-26 14:18:08.010681423 +0200
15 +#define LOGFILE_PATH "~/var/log/rrdcached.log"
16 +#define DATE_FORMAT "%Y-%m-%d %H:%M:%S "
17 +char g_logfile_path[512]; // Contains expanded path
20 +void log_to_file(char* format, ...);
21 +void set_logfile_path(void);
23 #define RRDD_LOG(severity, ...) \
25 if (stay_foreground) { \
26 fprintf(stderr, __VA_ARGS__); \
27 fprintf(stderr, "\n"); } \
28 - syslog ((severity), __VA_ARGS__); \
29 + log_to_file(__VA_ARGS__); \
32 +void log_to_file(char* format, ...)
35 + va_start(ap, format);
37 + time_t now = time(NULL);
38 + FILE *logfile_fd = fopen(g_logfile_path, "a+");
39 + strftime(g_date, sizeof(g_date), DATE_FORMAT, gmtime(&now));
40 + fprintf(logfile_fd, g_date, NULL);
41 + vfprintf(logfile_fd, format, ap);
44 + fprintf(logfile_fd, "\n");
49 +void set_logfile_path(void)
51 + wordexp_t exp_result;
52 + wordexp(LOGFILE_PATH, &exp_result, 0);
53 + strncpy(g_logfile_path, exp_result.we_wordv[0], sizeof(g_logfile_path));
56 #if defined(__FreeBSD__) || defined(__APPLE__)
57 #define RRD_LISTEN_BACKLOG -1
63 + // Determine logfile path within user directory
66 status = read_options (argc, argv);