Skip to content

Commit

Permalink
v1.0 hotfix (#10)
Browse files Browse the repository at this point in the history
* remove set_prefix calls

* fix timezone conversion issue

* do not print prefix if no prefix
  • Loading branch information
zyx-billy authored May 3, 2018
1 parent 476fddf commit 022e80c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 30 deletions.
1 change: 1 addition & 0 deletions lib/autolab/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion lib/logger/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 0 additions & 27 deletions src/cmd/cmdimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<Autolab::Enrollment> enrollments;
if (cmd.nargs() == 4) {
std::string action(cmd.args[2]);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 022e80c

Please sign in to comment.