From f27d0cf03a4274fde18a25c2fb9969638e59ca4c Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Tue, 22 Mar 2016 14:50:34 -0700 Subject: [PATCH] Capture logs for every binary To capture all information that is logged, change init_log() to make every log file name unique, and add a call to swupd_make_fullfiles to enable logging. Signed-off-by: Patrick McCarty --- include/swupd.h | 2 +- src/log.c | 7 ++++--- src/main.c | 2 +- src/make_fullfiles.c | 2 ++ src/make_packs.c | 6 ++---- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/swupd.h b/include/swupd.h index 184f959..e1bb4a7 100644 --- a/include/swupd.h +++ b/include/swupd.h @@ -222,7 +222,7 @@ extern void populate_file_struct(struct file *file, char *filename); extern void download_exta_base_content(void); extern char *get_elapsed_time(struct timeval *t1, struct timeval *t2); -extern void init_log(int version); +extern void init_log(const char *prefix, const char *bundle, int start, int end); extern void init_log_stdout(void); extern void close_log(int version, int exit_status); extern void __log_message(struct file *file, char *msg, char *filename, int linenr, const char *fmt, ...); diff --git a/src/log.c b/src/log.c index a5b33ab..10e641d 100644 --- a/src/log.c +++ b/src/log.c @@ -38,11 +38,12 @@ static FILE *logfile; static struct timeval start_time; -void init_log(int version) +void init_log(const char *prefix, const char *bundle, int start, int end) { - char filename[4096]; - sprintf(filename, "swupd-server.log.%i", version); + char *filename; + string_or_die(&filename, "%s%s-from-%i-to-%i.log", prefix, bundle, start, end); logfile = fopen(filename, "w"); + free(filename); gettimeofday(&start_time, NULL); } void init_log_stdout(void) diff --git a/src/main.c b/src/main.c index 761db73..5a9c7a3 100644 --- a/src/main.c +++ b/src/main.c @@ -274,7 +274,7 @@ int main(int argc, char **argv) populate_dirs(newversion); printf("Next version is %i \n", newversion); - init_log(newversion); + init_log("swupd-create-update", "", current_version, newversion); gettimeofday(&previous_time, NULL); diff --git a/src/make_fullfiles.c b/src/make_fullfiles.c index 5c795e6..1ae9be3 100644 --- a/src/make_fullfiles.c +++ b/src/make_fullfiles.c @@ -113,6 +113,8 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } + init_log("swupd-make-fullfiles", "", 0, version); + manifest = manifest_from_file(version, "full"); create_fullfiles(manifest); diff --git a/src/make_packs.c b/src/make_packs.c index abc7b4f..5c26443 100644 --- a/src/make_packs.c +++ b/src/make_packs.c @@ -116,10 +116,6 @@ int main(int argc, char **argv) banner(); check_root(); - /* FIXME: should use "end_version" not "0" and a unique filename - init_log(0); - */ - /* Initilize the crypto signature module */ if (!signature_initialize()) { printf("Can't initialize the crypto signature module!\n"); @@ -141,6 +137,8 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } + init_log("swupd-make-pack-", module, start_version, end_version); + printf("Making pack-%s %i to %li\n", module, start_version, end_version); pack = calloc(1, sizeof(struct packdata));