* Logger.h:

* SimpleLogger.{h,cc}: Changed the type of msg to const char*.
pull/1/head
Tatsuhiro Tsujikawa 2006-03-01 07:14:52 +00:00
parent 583e09780b
commit dd26d75751
6 changed files with 27 additions and 25 deletions

View File

@ -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 <tujikawa at rednoah dot com>

View File

@ -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_

View File

@ -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;

View File

@ -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());
}

View File

@ -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);

View File

@ -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_