瀏覽代碼

2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Moved non-trivial functions to *.cc file
	* src/Logger.cc
	* src/Logger.h
Tatsuhiro Tsujikawa 15 年之前
父節點
當前提交
cb134cc426
共有 4 個文件被更改,包括 138 次插入99 次删除
  1. 6 0
      ChangeLog
  2. 95 0
      src/Logger.cc
  3. 12 85
      src/Logger.h
  4. 25 14
      src/Makefile.in

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2010-06-20  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Moved non-trivial functions to *.cc file
+	* src/Logger.cc
+	* src/Logger.h
+
 2010-06-20  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Added separete *.cc files for exception classes.

+ 95 - 0
src/Logger.cc

@@ -76,4 +76,99 @@ void Logger::closeFile()
   }
 }
 
+#define WRITE_LOG(LEVEL, LEVEL_LABEL, MSG)              \
+  if(LEVEL >= _logLevel && _file.is_open()) {           \
+    va_list ap;                                         \
+    va_start(ap, MSG);                                  \
+    writeLog(_file, LEVEL, LEVEL_LABEL, MSG, ap);       \
+    va_end(ap);                                         \
+    _file << std::flush;                                \
+  }                                                     \
+  if(_stdoutField&LEVEL) {                              \
+    std::cout << "\n";                                  \
+    va_list ap;                                         \
+    va_start(ap, MSG);                                  \
+    writeLog(std::cout, LEVEL, LEVEL_LABEL, MSG, ap);   \
+    va_end(ap);                                         \
+    std::cout << std::flush;                            \
+  }                                                     \
+
+#define WRITE_LOG_EX(LEVEL, LEVEL_LABEL, MSG, EX)       \
+  if(LEVEL >= _logLevel && _file.is_open()) {           \
+    va_list ap;                                         \
+    va_start(ap, EX);                                   \
+    writeLog(_file, LEVEL, LEVEL_LABEL, MSG, ap);       \
+    va_end(ap);                                         \
+    writeStackTrace(_file, LEVEL, LEVEL_LABEL, EX);     \
+    _file << std::flush;                                \
+  }                                                     \
+  if(_stdoutField&LEVEL) {                              \
+    std::cout << "\n";                                  \
+    va_list ap;                                         \
+    va_start(ap, EX);                                   \
+    writeLog(std::cout, LEVEL, LEVEL_LABEL, MSG, ap);   \
+    va_end(ap);                                         \
+    writeStackTrace(std::cout, LEVEL, LEVEL_LABEL, EX); \
+    std::cout << std::flush;                            \
+  }                                                     \
+
+void Logger::debug(const char* msg, ...)
+{
+  WRITE_LOG(A2_DEBUG, DEBUG_LABEL, msg);
+}
+
+void Logger::debug(const char* msg, const Exception& ex, ...)
+{
+  WRITE_LOG_EX(A2_DEBUG, DEBUG_LABEL, msg, ex);
+}
+
+void Logger::info(const char* msg, ...)
+{
+  WRITE_LOG(A2_INFO, INFO_LABEL, msg);
+}
+
+void Logger::info(const char* msg, const Exception& ex, ...)
+{
+  WRITE_LOG_EX(A2_INFO, INFO_LABEL, msg, ex);
+}
+
+void Logger::notice(const char* msg, ...)
+{
+  WRITE_LOG(A2_NOTICE, NOTICE_LABEL, msg);
+}
+
+void Logger::notice(const char* msg, const Exception& ex, ...)
+{
+  WRITE_LOG_EX(A2_NOTICE, NOTICE_LABEL, msg, ex);
+}
+
+void Logger::warn(const char* msg, ...)
+{
+  WRITE_LOG(A2_WARN, WARN_LABEL, msg);
+}
+
+void Logger::warn(const char* msg, const Exception& ex, ...)
+{
+  WRITE_LOG_EX(A2_WARN, WARN_LABEL, msg, ex);
+}
+
+void Logger::error(const char*  msg, ...)
+{
+  WRITE_LOG(A2_ERROR, ERROR_LABEL, msg);
+}
+
+void Logger::error(const char* msg, const Exception& ex, ...)
+{
+  WRITE_LOG_EX(A2_ERROR, ERROR_LABEL, msg, ex);
+}
+
+void Logger::setStdoutLogLevel(Logger::LEVEL level, bool enabled)
+{
+  if(enabled) {
+    _stdoutField |= level;
+  } else {
+    _stdoutField &= ~level;
+  }
+}
+
 } // namespace aria2

+ 12 - 85
src/Logger.h

@@ -72,7 +72,7 @@ private:
 
   int _stdoutField;
   
-  inline bool levelEnabled(LEVEL level)
+  bool levelEnabled(LEVEL level)
   {
     return (level >= _logLevel && _file.is_open()) || _stdoutField&level;
   }
@@ -89,91 +89,25 @@ public:
 
   virtual ~Logger();
 
-#define WRITE_LOG(LEVEL, LEVEL_LABEL, MSG)              \
-  if(LEVEL >= _logLevel && _file.is_open()) {           \
-    va_list ap;                                         \
-    va_start(ap, MSG);                                  \
-    writeLog(_file, LEVEL, LEVEL_LABEL, MSG, ap);       \
-    va_end(ap);                                         \
-    _file << std::flush;                                \
-  }                                                     \
-  if(_stdoutField&LEVEL) {                              \
-    std::cout << "\n";                                  \
-    va_list ap;                                         \
-    va_start(ap, MSG);                                  \
-    writeLog(std::cout, LEVEL, LEVEL_LABEL, MSG, ap);   \
-    va_end(ap);                                         \
-    std::cout << std::flush;                            \
-  }                                                     \
-
-#define WRITE_LOG_EX(LEVEL, LEVEL_LABEL, MSG, EX)       \
-  if(LEVEL >= _logLevel && _file.is_open()) {           \
-    va_list ap;                                         \
-    va_start(ap, EX);                                   \
-    writeLog(_file, LEVEL, LEVEL_LABEL, MSG, ap);       \
-    va_end(ap);                                         \
-    writeStackTrace(_file, LEVEL, LEVEL_LABEL, EX);     \
-    _file << std::flush;                                \
-  }                                                     \
-  if(_stdoutField&LEVEL) {                              \
-    std::cout << "\n";                                  \
-    va_list ap;                                         \
-    va_start(ap, EX);                                   \
-    writeLog(std::cout, LEVEL, LEVEL_LABEL, MSG, ap);   \
-    va_end(ap);                                         \
-    writeStackTrace(std::cout, LEVEL, LEVEL_LABEL, EX); \
-    std::cout << std::flush;                            \
-  }                                                     \
-
-  void debug(const char* msg, ...)
-  {
-    WRITE_LOG(A2_DEBUG, DEBUG_LABEL, msg);
-  }
+  void debug(const char* msg, ...);
 
-  void debug(const char* msg, const Exception& ex, ...)
-  {
-    WRITE_LOG_EX(A2_DEBUG, DEBUG_LABEL, msg, ex);
-  }
+  void debug(const char* msg, const Exception& ex, ...);
 
-  void info(const char* msg, ...)
-  {
-    WRITE_LOG(A2_INFO, INFO_LABEL, msg);
-  }
+  void info(const char* msg, ...);
 
-  void info(const char* msg, const Exception& ex, ...)
-  {
-    WRITE_LOG_EX(A2_INFO, INFO_LABEL, msg, ex);
-  }
+  void info(const char* msg, const Exception& ex, ...);
 
-  void notice(const char* msg, ...)
-  {
-    WRITE_LOG(A2_NOTICE, NOTICE_LABEL, msg);
-  }
+  void notice(const char* msg, ...);
 
-  void notice(const char* msg, const Exception& ex, ...)
-  {
-    WRITE_LOG_EX(A2_NOTICE, NOTICE_LABEL, msg, ex);
-  }
+  void notice(const char* msg, const Exception& ex, ...);
 
-  void warn(const char* msg, ...)
-  {
-    WRITE_LOG(A2_WARN, WARN_LABEL, msg);
-  }
+  void warn(const char* msg, ...);
 
-  void warn(const char* msg, const Exception& ex, ...)
-  {
-    WRITE_LOG_EX(A2_WARN, WARN_LABEL, msg, ex);
-  }
+  void warn(const char* msg, const Exception& ex, ...);
 
-  void error(const char*  msg, ...)
-  {
-    WRITE_LOG(A2_ERROR, ERROR_LABEL, msg);
-  }
+  void error(const char*  msg, ...);
 
-  void error(const char* msg, const Exception& ex, ...)
-  {
-    WRITE_LOG_EX(A2_ERROR, ERROR_LABEL, msg, ex);
-  }
+  void error(const char* msg, const Exception& ex, ...);
 
   void openFile(const std::string& filename);
 
@@ -184,14 +118,7 @@ public:
     _logLevel = level;
   }
 
-  void setStdoutLogLevel(Logger::LEVEL level, bool enabled)
-  {
-    if(enabled) {
-      _stdoutField |= level;
-    } else {
-      _stdoutField &= ~level;
-    }
-  }
+  void setStdoutLogLevel(Logger::LEVEL level, bool enabled);
 
   // Returns true if this logger actually writes debug log message to
   // either file or stdout.

+ 25 - 14
src/Makefile.in

@@ -339,8 +339,10 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
 	DownloadEngine.cc DownloadEngine.h Segment.h GrowSegment.cc \
 	GrowSegment.h PiecedSegment.cc PiecedSegment.h SegmentMan.cc \
 	SegmentMan.h util.cc util.h Request.cc Request.h common.h \
-	message.h Exception.cc Exception.h FatalException.h \
-	RecoverableException.h DlAbortEx.h DlRetryEx.h \
+	message.h Exception.cc Exception.h FatalException.cc \
+	FatalException.h RecoverableException.cc \
+	RecoverableException.h DlAbortEx.cc DlAbortEx.h DlRetryEx.cc \
+	DlRetryEx.h DownloadFailureException.cc \
 	DownloadFailureException.h Logger.cc Logger.h SimpleLogger.cc \
 	SimpleLogger.h DiskWriter.h DiskWriterFactory.h \
 	AbstractDiskWriter.cc AbstractDiskWriter.h \
@@ -812,16 +814,18 @@ am__objects_32 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
 	FtpTunnelResponseCommand.$(OBJEXT) SleepCommand.$(OBJEXT) \
 	DownloadEngine.$(OBJEXT) GrowSegment.$(OBJEXT) \
 	PiecedSegment.$(OBJEXT) SegmentMan.$(OBJEXT) util.$(OBJEXT) \
-	Request.$(OBJEXT) Exception.$(OBJEXT) Logger.$(OBJEXT) \
-	SimpleLogger.$(OBJEXT) AbstractDiskWriter.$(OBJEXT) \
-	DefaultDiskWriter.$(OBJEXT) DefaultDiskWriterFactory.$(OBJEXT) \
-	File.$(OBJEXT) Option.$(OBJEXT) Base64.$(OBJEXT) \
-	base32.$(OBJEXT) LogFactory.$(OBJEXT) TimerA2.$(OBJEXT) \
-	TimeA2.$(OBJEXT) FeatureConfig.$(OBJEXT) \
-	DownloadEngineFactory.$(OBJEXT) SpeedCalc.$(OBJEXT) \
-	BitfieldMan.$(OBJEXT) SimpleRandomizer.$(OBJEXT) \
-	HttpResponse.$(OBJEXT) HttpRequest.$(OBJEXT) \
-	AbstractProxyRequestCommand.$(OBJEXT) \
+	Request.$(OBJEXT) Exception.$(OBJEXT) FatalException.$(OBJEXT) \
+	RecoverableException.$(OBJEXT) DlAbortEx.$(OBJEXT) \
+	DlRetryEx.$(OBJEXT) DownloadFailureException.$(OBJEXT) \
+	Logger.$(OBJEXT) SimpleLogger.$(OBJEXT) \
+	AbstractDiskWriter.$(OBJEXT) DefaultDiskWriter.$(OBJEXT) \
+	DefaultDiskWriterFactory.$(OBJEXT) File.$(OBJEXT) \
+	Option.$(OBJEXT) Base64.$(OBJEXT) base32.$(OBJEXT) \
+	LogFactory.$(OBJEXT) TimerA2.$(OBJEXT) TimeA2.$(OBJEXT) \
+	FeatureConfig.$(OBJEXT) DownloadEngineFactory.$(OBJEXT) \
+	SpeedCalc.$(OBJEXT) BitfieldMan.$(OBJEXT) \
+	SimpleRandomizer.$(OBJEXT) HttpResponse.$(OBJEXT) \
+	HttpRequest.$(OBJEXT) AbstractProxyRequestCommand.$(OBJEXT) \
 	AbstractProxyResponseCommand.$(OBJEXT) Netrc.$(OBJEXT) \
 	AuthConfig.$(OBJEXT) AbstractAuthResolver.$(OBJEXT) \
 	DefaultAuthResolver.$(OBJEXT) NetrcAuthResolver.$(OBJEXT) \
@@ -1116,8 +1120,10 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
 	DownloadEngine.cc DownloadEngine.h Segment.h GrowSegment.cc \
 	GrowSegment.h PiecedSegment.cc PiecedSegment.h SegmentMan.cc \
 	SegmentMan.h util.cc util.h Request.cc Request.h common.h \
-	message.h Exception.cc Exception.h FatalException.h \
-	RecoverableException.h DlAbortEx.h DlRetryEx.h \
+	message.h Exception.cc Exception.h FatalException.cc \
+	FatalException.h RecoverableException.cc \
+	RecoverableException.h DlAbortEx.cc DlAbortEx.h DlRetryEx.cc \
+	DlRetryEx.h DownloadFailureException.cc \
 	DownloadFailureException.h Logger.cc Logger.h SimpleLogger.cc \
 	SimpleLogger.h DiskWriter.h DiskWriterFactory.h \
 	AbstractDiskWriter.cc AbstractDiskWriter.h \
@@ -1453,10 +1459,13 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultPieceStorage.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DirectDiskAdaptor.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DiskAdaptor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DlAbortEx.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DlRetryEx.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DownloadCommand.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DownloadContext.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DownloadEngine.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DownloadEngineFactory.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DownloadFailureException.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DownloadHandler.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DownloadHandlerConstants.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DownloadHandlerFactory.Po@am__quote@
@@ -1465,6 +1474,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ExpatMetalinkProcessor.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ExpatXmlRpcRequestProcessor.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FallocFileAllocationIterator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FatalException.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FeatureConfig.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FeedbackURISelector.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/File.Po@am__quote@
@@ -1572,6 +1582,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RarestPieceSelector.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RealtimeCommand.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ReceiverMSEHandshakeCommand.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RecoverableException.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroup.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroupEntry.Po@am__quote@