From 59976aed4e24c5778665bda87900bf3c860f4810 Mon Sep 17 00:00:00 2001 From: kernc Date: Tue, 10 Jan 2012 10:31:44 +0000 Subject: [PATCH] Fixed issue 45 (only --post-size rewrites old log) git-svn-id: https://logkeys.googlecode.com/svn/trunk@93 c501e62c-e7d1-11de-a198-37193048d1ed --- src/logkeys.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/logkeys.cc b/src/logkeys.cc index 30ea3c0..d3e6309 100644 --- a/src/logkeys.cc +++ b/src/logkeys.cc @@ -510,14 +510,22 @@ int main(int argc, char **argv) error(EXIT_FAILURE, errno, "Error opening output file '%s'", args.logfile.c_str()); file_size = 0; // new log file is now empty - // TODO: write new timestamp - switch (fork()) - { + // write new timestamp + time(&cur_time); + strftime(timestamp, sizeof(timestamp), TIME_FORMAT, localtime(&cur_time)); + if (args.flags & FLAG_NO_TIMESTAMPS) + file_size += fprintf(out, "Logging started at %s\n\n", timestamp); + else + file_size += fprintf(out, "Logging started ...\n\n%s", timestamp); + + if (!args.http_url.empty() || !args.irc_server.empty()) { + switch (fork()) { case -1: error(0, errno, "Error while forking remote-posting process"); case 0: start_remote_upload(); // child process will upload the .log.i files exit(EXIT_SUCCESS); + } } }