2007-06-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Changed format of log file.
	* src/SimpleLogger.cc
pull/1/head
Tatsuhiro Tsujikawa 2007-06-12 10:50:40 +00:00
parent cdbfde719e
commit ba6e5ac7e5
5 changed files with 15 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2007-06-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed format of log file.
* src/SimpleLogger.cc
2007-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2007-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/AbstractCommand.cc * src/AbstractCommand.cc

View File

@ -201,7 +201,7 @@ void BtPieceMessage::onNewPiece(const PieceHandle& piece) {
} }
void BtPieceMessage::onWrongPiece(const PieceHandle& piece) { void BtPieceMessage::onWrongPiece(const PieceHandle& piece) {
logger->error(MSG_GOT_WRONG_PIECE, cuid, piece->getIndex()); logger->info(MSG_GOT_WRONG_PIECE, cuid, piece->getIndex());
erasePieceOnDisk(piece); erasePieceOnDisk(piece);
piece->clearAllBlock(); piece->clearAllBlock();
requestFactory->removeTargetPiece(piece); requestFactory->removeTargetPiece(piece);

View File

@ -105,10 +105,9 @@ void RequestGroupMan::showDownloadResults(ostream& o) const
<<_("Download Results:") << "\n" <<_("Download Results:") << "\n"
<< "idx|stat|path/URI" << "\n" << "idx|stat|path/URI" << "\n"
<< "===+====+======================================================================" << "\n"; << "===+====+======================================================================" << "\n";
int32_t count = 0;
for(RequestGroups::const_iterator itr = _requestGroups.begin(); for(RequestGroups::const_iterator itr = _requestGroups.begin();
itr != _requestGroups.end(); ++itr) { itr != _requestGroups.end(); ++itr) {
o << setw(3) << ++count << "|"; o << setw(3) << (*itr)->getGID() << "|";
if((*itr)->downloadFinished()) { if((*itr)->downloadFinished()) {
o << "OK "; o << "OK ";
} else { } else {

View File

@ -81,7 +81,7 @@ void SimpleLogger::setStdout(int level, bool enabled) {
} }
void SimpleLogger::writeHeader(FILE* file, string date, string level) const { void SimpleLogger::writeHeader(FILE* file, string date, string level) const {
fprintf(file, "%s - %s - ", date.c_str(), level.c_str()); fprintf(file, "%s %s - ", date.c_str(), level.c_str());
} }
void SimpleLogger::writeLog(FILE* file, int level, const char* msg, va_list ap, Exception* e, bool printHeader) const void SimpleLogger::writeLog(FILE* file, int level, const char* msg, va_list ap, Exception* e, bool printHeader) const
@ -105,9 +105,11 @@ void SimpleLogger::writeLog(FILE* file, int level, const char* msg, va_list ap,
levelStr = "INFO"; levelStr = "INFO";
} }
time_t now = time(NULL); time_t now = time(NULL);
char datestr[26]; char datestr[20];
ctime_r(&now, datestr); struct tm tm;
datestr[strlen(datestr)-1] = '\0'; localtime_r(&now, &tm);
strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm);
// TODO a quick hack not to print header in console // TODO a quick hack not to print header in console
if(printHeader) { if(printHeader) {
writeHeader(file, datestr, levelStr); writeHeader(file, datestr, levelStr);
@ -127,7 +129,7 @@ void SimpleLogger::writeFile(int level, const char* msg, va_list ap, Exception*
writeLog(file, level, msg, ap, e); writeLog(file, level, msg, ap, e);
if(stdoutField&level) { if(stdoutField&level) {
fprintf(stdout, "\n"); fprintf(stdout, "\n");
writeLog(stdout, level, msg, ap, e, false); writeLog(stdout, level, msg, ap, e);
} }
} }

View File

@ -41,7 +41,7 @@ class SimpleLogger:public Logger {
private: private:
void writeFile(int level, const char* msg, va_list ap, Exception* e = 0) const; void writeFile(int level, const char* msg, va_list ap, Exception* e = 0) const;
void writeHeader(FILE* file, string date, string level) const; void writeHeader(FILE* file, string date, string level) const;
void writeLog(FILE* file, int level, const char* msg, va_list ap, Exception* e = 0, bool printHeader = false) const; void writeLog(FILE* file, int level, const char* msg, va_list ap, Exception* e = 0, bool printHeader = true) const;
FILE* file; FILE* file;
int stdoutField; int stdoutField;
public: public: