From dd26d7575175f07f92851fe21437b89974561f19 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 1 Mar 2006 07:14:52 +0000 Subject: [PATCH] * Logger.h: * SimpleLogger.{h,cc}: Changed the type of msg to const char*. --- ChangeLog | 2 ++ src/Logger.h | 12 ++++++------ src/SegmentMan.cc | 2 +- src/SegmentSplitter.cc | 8 ++++---- src/SimpleLogger.cc | 14 +++++++------- src/SimpleLogger.h | 14 +++++++------- 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59b2250a..000e339b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ Added "User-Agent" header to CONNECT proxy request. Fixed "Proxy-Authorization" header. Now proxy authorization works properly. + * Logger.h: + * SimpleLogger.{h,cc}: Changed the type of msg to const char*. 2006-02-28 Tatsuhiro Tsujikawa diff --git a/src/Logger.h b/src/Logger.h index 66c5db8b..b82abbe8 100644 --- a/src/Logger.h +++ b/src/Logger.h @@ -31,12 +31,12 @@ using namespace std; class Logger { public: virtual ~Logger() {} - virtual void debug(string msg, ...) const = 0; - virtual void debug(string msg, Exception* ex, ...) const = 0; - virtual void info(string msg, ...) const = 0; - virtual void info(string msg, Exception* ex, ...) const = 0; - virtual void error(string msg, ...) const = 0; - virtual void error(string msg, Exception* ex, ...) const = 0; + virtual void debug(const char* msg, ...) const = 0; + virtual void debug(const char* msg, Exception* ex, ...) const = 0; + virtual void info(const char* msg, ...) const = 0; + virtual void info(const char* msg, Exception* ex, ...) const = 0; + virtual void error(const char* msg, ...) const = 0; + virtual void error(const char* msg, Exception* ex, ...) const = 0; }; #endif // _D_LOGGER_H_ diff --git a/src/SegmentMan.cc b/src/SegmentMan.cc index 8046bf7b..57accd15 100644 --- a/src/SegmentMan.cc +++ b/src/SegmentMan.cc @@ -46,7 +46,7 @@ bool SegmentMan::getSegment(Segment& seg, int cuid) { //Segment s = { 0, 0, 0, false }; if(segments.empty()) { - logger->debug("assign new segment { sp = 0, ep = "+(totalSize == 0 ? "0" : Util::llitos(totalSize-1))+" } to cuid "+Util::llitos(cuid)); + logger->debug(string("assign new segment { sp = 0, ep = "+(totalSize == 0 ? "0" : Util::llitos(totalSize-1))+" } to cuid "+Util::llitos(cuid)).c_str()); //seg = { cuid, 0, totalSize == 0 ? 0 : totalSize-1, 0, false }; seg.cuid = cuid; seg.sp = 0; diff --git a/src/SegmentSplitter.cc b/src/SegmentSplitter.cc index ef144d1f..774f65bb 100644 --- a/src/SegmentSplitter.cc +++ b/src/SegmentSplitter.cc @@ -31,16 +31,16 @@ void SegmentSplitter::split(Segment& seg, int cuid, Segment& s) const { seg.speed = s.speed; seg.finish = false; s.ep = nep; - logger->debug("return new segment { " + logger->debug(string("return new segment { " "sp = "+Util::llitos(seg.sp)+", "+ "ep = "+Util::llitos(seg.ep)+", "+ "ds = "+Util::llitos(seg.ds)+", "+ "speed = "+Util::itos(seg.speed)+" } to "+ - "cuid "+Util::llitos(cuid)); - logger->debug("update segment { " + "cuid "+Util::llitos(cuid)).c_str()); + logger->debug(string("update segment { " "sp = "+Util::llitos(s.sp)+", "+ "ep = "+Util::llitos(s.ep)+", "+ "ds = "+Util::llitos(s.ds)+", "+ "speed = "+Util::itos(s.speed)+" } of "+ - "cuid "+Util::llitos(s.cuid)); + "cuid "+Util::llitos(s.cuid)).c_str()); } diff --git a/src/SimpleLogger.cc b/src/SimpleLogger.cc index efb95374..2de0dbe7 100644 --- a/src/SimpleLogger.cc +++ b/src/SimpleLogger.cc @@ -38,7 +38,7 @@ SimpleLogger::~SimpleLogger() { } } -void SimpleLogger::writeLog(int level, string msg, va_list ap, Exception* e) const +void SimpleLogger::writeLog(int level, const char* msg, va_list ap, Exception* e) const { string levelStr; switch(level) { @@ -63,14 +63,14 @@ void SimpleLogger::writeLog(int level, string msg, va_list ap, Exception* e) con fflush(stdout); } -void SimpleLogger::debug(string msg, ...) const { +void SimpleLogger::debug(const char* msg, ...) const { va_list ap; va_start(ap, msg); writeLog(DEBUG, msg, ap); va_end(ap); } -void SimpleLogger::debug(string msg, Exception* e, ...) const { +void SimpleLogger::debug(const char* msg, Exception* e, ...) const { va_list ap; va_start(ap, e); writeLog(DEBUG, msg, ap, e); @@ -78,14 +78,14 @@ void SimpleLogger::debug(string msg, Exception* e, ...) const { } -void SimpleLogger::info(string msg, ...) const { +void SimpleLogger::info(const char* msg, ...) const { va_list ap; va_start(ap, msg); writeLog(INFO, msg, ap); va_end(ap); } -void SimpleLogger::info(string msg, Exception* e, ...) const { +void SimpleLogger::info(const char* msg, Exception* e, ...) const { va_list ap; va_start(ap, e); writeLog(INFO, msg, ap, e); @@ -93,14 +93,14 @@ void SimpleLogger::info(string msg, Exception* e, ...) const { } -void SimpleLogger::error(string msg, ...) const { +void SimpleLogger::error(const char* msg, ...) const { va_list ap; va_start(ap, msg); writeLog(ERROR, msg, ap); va_end(ap); } -void SimpleLogger::error(string msg, Exception* e, ...) const { +void SimpleLogger::error(const char* msg, Exception* e, ...) const { va_list ap; va_start(ap, e); writeLog(ERROR, msg, ap, e); diff --git a/src/SimpleLogger.h b/src/SimpleLogger.h index 5caab527..72a53e16 100644 --- a/src/SimpleLogger.h +++ b/src/SimpleLogger.h @@ -30,19 +30,19 @@ private: DEBUG, INFO, ERROR}; - void writeLog(int level, string msg, va_list ap, Exception* e = NULL) const; + void writeLog(int level, const char* msg, va_list ap, Exception* e = NULL) const; FILE* file; public: SimpleLogger(string filename); SimpleLogger(FILE* logfile); ~SimpleLogger(); - void debug(string msg, ...) const; - void debug(string msg, Exception* ex, ...) const; - void info(string msg, ...) const; - void info(string msg, Exception* ex, ...) const; - void error(string msg, ...) const; - void error(string msg, Exception* ex, ...) const; + void debug(const char* msg, ...) const; + void debug(const char* msg, Exception* ex, ...) const; + void info(const char* msg, ...) const; + void info(const char* msg, Exception* ex, ...) const; + void error(const char* msg, ...) const; + void error(const char* msg, Exception* ex, ...) const; }; #endif // _D_SIMPLE_LOGGER_H_