diff --git a/ChangeLog b/ChangeLog index e675e2514..f230f3ffd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-24 Tatsuhiro Tsujikawa + + Externalized message. + * src/RequestGroupMan.cc + * src/message.h + 2008-08-24 Tatsuhiro Tsujikawa Save temporary file first and rename to the destination on success. diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 9cc4ce72a..fc9a61f57 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -483,16 +483,14 @@ bool RequestGroupMan::loadServerStat(const std::string& filename) { std::ifstream in(filename.c_str()); if(!in) { - _logger->error("Failed to open ServerStat file %s for read.", - filename.c_str()); + _logger->error(MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED, filename.c_str()); return false; } if(_serverStatMan->load(in)) { - _logger->notice("ServerStat file %s loaded successfully.", - filename.c_str()); + _logger->notice(MSG_SERVER_STAT_LOADED, filename.c_str()); return true; } else { - _logger->error("Failed to read ServerStat from %s.", filename.c_str()); + _logger->error(MSG_READING_SERVER_STAT_FILE_FAILED, filename.c_str()); return false; } } @@ -502,15 +500,15 @@ bool RequestGroupMan::saveServerStat(const std::string& filename) const std::string tempfile = filename+"__temp"; std::ofstream out(tempfile.c_str()); if(!out) { - _logger->error("Failed to open ServerStat file %s for write.", + _logger->error(MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED, tempfile.c_str()); return false; } if(_serverStatMan->save(out) && File(tempfile).renameTo(filename)) { - _logger->notice("ServerStat file %s saved successfully.", filename.c_str()); + _logger->notice(MSG_SERVER_STAT_SAVED, filename.c_str()); return true; } else { - _logger->error("Failed to write ServerStat to %s.", filename.c_str()); + _logger->error(MSG_WRITING_SERVER_STAT_FILE_FAILED, filename.c_str()); return false; } } diff --git a/src/message.h b/src/message.h index 31d1fe716..0584e3f6a 100644 --- a/src/message.h +++ b/src/message.h @@ -144,6 +144,16 @@ " doesn't verify signatures.") #define MSG_SIGNATURE_NOT_SAVED _("Saving signature as %s failed. Maybe file"\ " already exists.") +#define MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED \ + _("Failed to open ServerStat file %s for read.") +#define MSG_SERVER_STAT_LOADED _("ServerStat file %s loaded successfully.") +#define MSG_READING_SERVER_STAT_FILE_FAILED _("Failed to read ServerStat from" \ + " %s.") +#define MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED \ + _("Failed to open ServerStat file %s for write.") +#define MSG_SERVER_STAT_SAVED _("ServerStat file %s saved successfully.") +#define MSG_WRITING_SERVER_STAT_FILE_FAILED _("Failed to write ServerStat to"\ + " %s.") #define EX_TIME_OUT _("Timeout.") #define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")