mirror of https://github.com/aria2/aria2
* Logger.h:
* SimpleLogger.{h,cc}: Changed the type of msg to const char*.pull/1/head
parent
583e09780b
commit
dd26d75751
|
@ -9,6 +9,8 @@
|
||||||
Added "User-Agent" header to CONNECT proxy request.
|
Added "User-Agent" header to CONNECT proxy request.
|
||||||
Fixed "Proxy-Authorization" header. Now proxy authorization works
|
Fixed "Proxy-Authorization" header. Now proxy authorization works
|
||||||
properly.
|
properly.
|
||||||
|
* Logger.h:
|
||||||
|
* SimpleLogger.{h,cc}: Changed the type of msg to const char*.
|
||||||
|
|
||||||
2006-02-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2006-02-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
|
12
src/Logger.h
12
src/Logger.h
|
@ -31,12 +31,12 @@ using namespace std;
|
||||||
class Logger {
|
class Logger {
|
||||||
public:
|
public:
|
||||||
virtual ~Logger() {}
|
virtual ~Logger() {}
|
||||||
virtual void debug(string msg, ...) const = 0;
|
virtual void debug(const char* msg, ...) const = 0;
|
||||||
virtual void debug(string msg, Exception* ex, ...) const = 0;
|
virtual void debug(const char* msg, Exception* ex, ...) const = 0;
|
||||||
virtual void info(string msg, ...) const = 0;
|
virtual void info(const char* msg, ...) const = 0;
|
||||||
virtual void info(string msg, Exception* ex, ...) const = 0;
|
virtual void info(const char* msg, Exception* ex, ...) const = 0;
|
||||||
virtual void error(string msg, ...) const = 0;
|
virtual void error(const char* msg, ...) const = 0;
|
||||||
virtual void error(string msg, Exception* ex, ...) const = 0;
|
virtual void error(const char* msg, Exception* ex, ...) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _D_LOGGER_H_
|
#endif // _D_LOGGER_H_
|
||||||
|
|
|
@ -46,7 +46,7 @@ bool SegmentMan::getSegment(Segment& seg, int cuid) {
|
||||||
//Segment s = { 0, 0, 0, false };
|
//Segment s = { 0, 0, 0, false };
|
||||||
|
|
||||||
if(segments.empty()) {
|
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, 0, totalSize == 0 ? 0 : totalSize-1, 0, false };
|
||||||
seg.cuid = cuid;
|
seg.cuid = cuid;
|
||||||
seg.sp = 0;
|
seg.sp = 0;
|
||||||
|
|
|
@ -31,16 +31,16 @@ void SegmentSplitter::split(Segment& seg, int cuid, Segment& s) const {
|
||||||
seg.speed = s.speed;
|
seg.speed = s.speed;
|
||||||
seg.finish = false;
|
seg.finish = false;
|
||||||
s.ep = nep;
|
s.ep = nep;
|
||||||
logger->debug("return new segment { "
|
logger->debug(string("return new segment { "
|
||||||
"sp = "+Util::llitos(seg.sp)+", "+
|
"sp = "+Util::llitos(seg.sp)+", "+
|
||||||
"ep = "+Util::llitos(seg.ep)+", "+
|
"ep = "+Util::llitos(seg.ep)+", "+
|
||||||
"ds = "+Util::llitos(seg.ds)+", "+
|
"ds = "+Util::llitos(seg.ds)+", "+
|
||||||
"speed = "+Util::itos(seg.speed)+" } to "+
|
"speed = "+Util::itos(seg.speed)+" } to "+
|
||||||
"cuid "+Util::llitos(cuid));
|
"cuid "+Util::llitos(cuid)).c_str());
|
||||||
logger->debug("update segment { "
|
logger->debug(string("update segment { "
|
||||||
"sp = "+Util::llitos(s.sp)+", "+
|
"sp = "+Util::llitos(s.sp)+", "+
|
||||||
"ep = "+Util::llitos(s.ep)+", "+
|
"ep = "+Util::llitos(s.ep)+", "+
|
||||||
"ds = "+Util::llitos(s.ds)+", "+
|
"ds = "+Util::llitos(s.ds)+", "+
|
||||||
"speed = "+Util::itos(s.speed)+" } of "+
|
"speed = "+Util::itos(s.speed)+" } of "+
|
||||||
"cuid "+Util::llitos(s.cuid));
|
"cuid "+Util::llitos(s.cuid)).c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
string levelStr;
|
||||||
switch(level) {
|
switch(level) {
|
||||||
|
@ -63,14 +63,14 @@ void SimpleLogger::writeLog(int level, string msg, va_list ap, Exception* e) con
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleLogger::debug(string msg, ...) const {
|
void SimpleLogger::debug(const char* msg, ...) const {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
writeLog(DEBUG, msg, ap);
|
writeLog(DEBUG, msg, ap);
|
||||||
va_end(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_list ap;
|
||||||
va_start(ap, e);
|
va_start(ap, e);
|
||||||
writeLog(DEBUG, msg, 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_list ap;
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
writeLog(INFO, msg, ap);
|
writeLog(INFO, msg, ap);
|
||||||
va_end(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_list ap;
|
||||||
va_start(ap, e);
|
va_start(ap, e);
|
||||||
writeLog(INFO, msg, 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_list ap;
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
writeLog(ERROR, msg, ap);
|
writeLog(ERROR, msg, ap);
|
||||||
va_end(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_list ap;
|
||||||
va_start(ap, e);
|
va_start(ap, e);
|
||||||
writeLog(ERROR, msg, ap, e);
|
writeLog(ERROR, msg, ap, e);
|
||||||
|
|
|
@ -30,19 +30,19 @@ private:
|
||||||
DEBUG,
|
DEBUG,
|
||||||
INFO,
|
INFO,
|
||||||
ERROR};
|
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;
|
FILE* file;
|
||||||
public:
|
public:
|
||||||
SimpleLogger(string filename);
|
SimpleLogger(string filename);
|
||||||
SimpleLogger(FILE* logfile);
|
SimpleLogger(FILE* logfile);
|
||||||
~SimpleLogger();
|
~SimpleLogger();
|
||||||
|
|
||||||
void debug(string msg, ...) const;
|
void debug(const char* msg, ...) const;
|
||||||
void debug(string msg, Exception* ex, ...) const;
|
void debug(const char* msg, Exception* ex, ...) const;
|
||||||
void info(string msg, ...) const;
|
void info(const char* msg, ...) const;
|
||||||
void info(string msg, Exception* ex, ...) const;
|
void info(const char* msg, Exception* ex, ...) const;
|
||||||
void error(string msg, ...) const;
|
void error(const char* msg, ...) const;
|
||||||
void error(string msg, Exception* ex, ...) const;
|
void error(const char* msg, Exception* ex, ...) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _D_SIMPLE_LOGGER_H_
|
#endif // _D_SIMPLE_LOGGER_H_
|
||||||
|
|
Loading…
Reference in New Issue