Adds date and time specifier for the log file name.

This commit is contained in:
Andrea Mazzoleni 2014-02-16 10:03:02 +01:00
parent f6c2ae14de
commit cb0a280ddc
9 changed files with 154 additions and 31 deletions

11
state.c
View file

@ -347,6 +347,8 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
unsigned line;
tommy_node* i;
unsigned l;
time_t t;
struct tm* tm;
/* copy the options */
state->opt = *opt;
@ -357,7 +359,16 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
state->command = command;
t = time(0);
tm = localtime(&t);
fprintf(stdlog, "version:%s\n", PACKAGE_VERSION);
fprintf(stdlog, "unixtime:%"PRIi64"\n", (int64_t)t);
if (tm) {
char datetime[64];
strftime(datetime, sizeof(datetime), "%F %T", tm);
fprintf(stdlog, "time:%s\n", datetime);
}
fprintf(stdlog, "conf:%s\n", path);
fflush(stdlog);