mirror of
https://github.com/aria2/aria2.git
synced 2025-04-06 05:57:36 +03:00
2010-06-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made log and log-level option modifiable using aria2.changeGlobalOption. This means you can dynamically start or stop logging and change log file and log level. * doc/aria2c.1.txt * src/LogFactory.cc * src/LogFactory.h * src/LogFormatter.h * src/Logger.cc * src/Logger.h * src/Makefile.am * src/Makefile.in * src/SimpleLogFormatter.cc * src/SimpleLogFormatter.h * src/SimpleLogger.cc: Removed * src/SimpleLogger.h: Removed * src/XmlRpcMethod.cc * src/XmlRpcMethodImpl.cc * src/main.cc
This commit is contained in:
parent
4736e77acf
commit
66660d10c2
16 changed files with 239 additions and 60 deletions
|
@ -40,6 +40,7 @@
|
|||
#include "DlAbortEx.h"
|
||||
#include "StringFormat.h"
|
||||
#include "message.h"
|
||||
#include "LogFormatter.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -53,11 +54,13 @@ const std::string Logger::ERROR_LABEL("ERROR");
|
|||
|
||||
const std::string Logger::INFO_LABEL("INFO");
|
||||
|
||||
Logger::Logger():logLevel_(Logger::A2_DEBUG), stdoutField_(0) {}
|
||||
Logger::Logger():
|
||||
logFormatter_(0), logLevel_(Logger::A2_DEBUG), stdoutField_(0) {}
|
||||
|
||||
Logger::~Logger()
|
||||
{
|
||||
closeFile();
|
||||
delete logFormatter_;
|
||||
}
|
||||
|
||||
void Logger::openFile(const std::string& filename)
|
||||
|
@ -162,6 +165,12 @@ void Logger::error(const char* msg, const Exception& ex, ...)
|
|||
WRITE_LOG_EX(A2_ERROR, ERROR_LABEL, msg, ex);
|
||||
}
|
||||
|
||||
void Logger::setLogFormatter(LogFormatter* logFormatter)
|
||||
{
|
||||
delete logFormatter_;
|
||||
logFormatter_ = logFormatter;
|
||||
}
|
||||
|
||||
void Logger::setStdoutLogLevel(Logger::LEVEL level, bool enabled)
|
||||
{
|
||||
if(enabled) {
|
||||
|
@ -171,4 +180,22 @@ void Logger::setStdoutLogLevel(Logger::LEVEL level, bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
void Logger::writeLog
|
||||
(std::ostream& o, LEVEL logLevel, const std::string& logLevelLabel,
|
||||
const char* msg, va_list ap)
|
||||
{
|
||||
if(logFormatter_) {
|
||||
logFormatter_->writeLog(o, logLevel, logLevelLabel, msg, ap);
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::writeStackTrace
|
||||
(std::ostream& o, LEVEL logLevel, const std::string& logLevelLabel,
|
||||
const Exception& ex)
|
||||
{
|
||||
if(logFormatter_) {
|
||||
logFormatter_->writeStackTrace(o, logLevel, logLevelLabel, ex);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue