From 022e80c6180a5ad8eacc283281704b45d80a93ed Mon Sep 17 00:00:00 2001 From: Billy Zhu Date: Thu, 3 May 2018 15:08:49 -0400 Subject: [PATCH] v1.0 hotfix (#10) * remove set_prefix calls * fix timezone conversion issue * do not print prefix if no prefix --- lib/autolab/utility.cpp | 1 + lib/logger/logger.h | 5 ++++- src/cmd/cmdimp.cpp | 27 --------------------------- src/main.cpp | 2 -- 4 files changed, 5 insertions(+), 30 deletions(-) diff --git a/lib/autolab/utility.cpp b/lib/autolab/utility.cpp index ad6379f..cdb0a96 100644 --- a/lib/autolab/utility.cpp +++ b/lib/autolab/utility.cpp @@ -20,6 +20,7 @@ double get_timezone_offset() { std::time(&raw_time_utc); std::tm *utc = std::gmtime(&raw_time_utc); + utc->tm_isdst = -1; std::time_t raw_time_local = std::mktime(utc); double diff_in_seconds = std::difftime(raw_time_utc, raw_time_local); diff --git a/lib/logger/logger.h b/lib/logger/logger.h index fa4a0f9..142da9a 100644 --- a/lib/logger/logger.h +++ b/lib/logger/logger.h @@ -52,7 +52,10 @@ namespace Logger { fatal_logger &operator<<(T val) { if (!prefix_used) { prefix_used = true; - std::cerr << "fatal: " << prefix << std::endl; + std::cerr << "fatal: "; + if (prefix.length() > 0) { + std::cerr << prefix << std::endl; + } } std::cerr << val; return *this; diff --git a/src/cmd/cmdimp.cpp b/src/cmd/cmdimp.cpp index a23abe7..e8b5a57 100644 --- a/src/cmd/cmdimp.cpp +++ b/src/cmd/cmdimp.cpp @@ -162,9 +162,6 @@ int show_status(cmdargs &cmd) { "directory, the details of the assessment will be shown."); cmd.setup_done(); - // set up logger - Logger::fatal.set_prefix("Cannot show status"); - std::string course_name, asmt_name; bool in_asmt_dir = read_asmt_file(course_name, asmt_name); if (!in_asmt_dir) { @@ -214,9 +211,6 @@ int download_asmt(cmdargs &cmd) { cmd.new_arg("course_name:assessment_name", true); cmd.setup_done(); - // set up logger - Logger::fatal.set_prefix("Cannot download assessment"); - // parse course and assessment name std::string course_name, asmt_name; parse_course_and_asmt(cmd.args[2], course_name, asmt_name); @@ -300,9 +294,6 @@ int submit_asmt(cmdargs &cmd) { std::string course_name, asmt_name, filename; - // set up logger - Logger::fatal.set_prefix("Cannot submit assessment"); - if (cmd.nargs() >= 4) { // user provided course and assessment name with filename parse_course_and_asmt(cmd.args[2], course_name, asmt_name); @@ -409,9 +400,6 @@ int show_courses(cmdargs &cmd) { "List all current courses of the user."); cmd.setup_done(); - // set up logger - Logger::fatal.set_prefix("Cannot get courses"); - // hidden option --use-cache if (cmd.has_option("-u", "--use-cache")) { print_course_cache_entry(); @@ -471,9 +459,6 @@ int manage_enrolls(cmdargs &cmd) { "enrollment data after new, edit, or delete"); cmd.setup_done(); - // set up logger - Logger::fatal.set_prefix("Cannot get enrollments"); - std::vector enrollments; if (cmd.nargs() == 4) { std::string action(cmd.args[2]); @@ -573,9 +558,6 @@ int show_assessments(cmdargs &cmd) { cmd.new_arg("course_name", true); cmd.setup_done(); - // set up logger - Logger::fatal.set_prefix("Cannot get assessments"); - std::string course_name(cmd.args[2]); // hidden option --use-cache @@ -622,9 +604,6 @@ int show_problems(cmdargs &cmd) { cmd.new_arg("course_name:assessment_name", false); cmd.setup_done(); - // set up logger - Logger::fatal.set_prefix("Cannot get problems"); - std::string course_name, asmt_name; // user-specified names take precedence if (cmd.nargs() >= 3) { @@ -662,9 +641,6 @@ int show_scores(cmdargs &cmd) { "Show scores from all submission. Default shows only the latest"); cmd.setup_done(); - // set up logger - Logger::fatal.set_prefix("Cannot get scores"); - std::string course_name, asmt_name; // user-specified names take precedence if (cmd.nargs() >= 3) { @@ -713,9 +689,6 @@ int show_feedback(cmdargs &cmd) { "Get feedback for this particular version"); cmd.setup_done(); - // set up logger - Logger::fatal.set_prefix("Cannot get feedback"); - std::string course_name, asmt_name; // user-specified names take precedence if (cmd.nargs() >= 3) { diff --git a/src/main.cpp b/src/main.cpp index 03c9ca1..0c189a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -133,8 +133,6 @@ int main(int argc, char *argv[]) { if ("setup" == command) { return user_setup(cmd); } else { - Logger::fatal.set_prefix("Cannot start autolab client"); - if (!init_autolab_client()) { Logger::fatal << "No user set up on this client yet." << Logger::endl << Logger::endl