浏览代码

Fixed CID 1197474, CID 1366358

AlexVinS 9 年之前
父节点
当前提交
36598d8695
共有 5 个文件被更改,包括 17 次插入1 次删除
  1. 2 1
      include/vstd/CLoggerBase.h
  2. 1 0
      lib/VCMI_lib.cbp
  3. 12 0
      lib/logging/CLogger.cpp
  4. 1 0
      lib/logging/CLogger.h
  5. 1 0
      test/Test.cbp

+ 2 - 1
include/vstd/CLoggerBase.h

@@ -51,13 +51,14 @@ namespace vstd
 		virtual ~CLoggerBase(){};
 		virtual ~CLoggerBase(){};
 
 
 		virtual void log(ELogLevel::ELogLevel level, const std::string & message) const = 0;
 		virtual void log(ELogLevel::ELogLevel level, const std::string & message) const = 0;
+		virtual void log(ELogLevel::ELogLevel level, const boost::format & fmt) const = 0;
 
 
 		template<typename T, typename ... Args>
 		template<typename T, typename ... Args>
 		void log(ELogLevel::ELogLevel level, const std::string & format, T t, Args ... args) const
 		void log(ELogLevel::ELogLevel level, const std::string & format, T t, Args ... args) const
 		{
 		{
 			boost::format fmt(format);
 			boost::format fmt(format);
 			makeFormat(fmt, t, args...);
 			makeFormat(fmt, t, args...);
-			log(level, fmt.str());
+			log(level, fmt);
 		}
 		}
 
 
 		/// Log methods for various log levels
 		/// Log methods for various log levels

+ 1 - 0
lib/VCMI_lib.cbp

@@ -153,6 +153,7 @@
 		<Unit filename="CGameInterface.h" />
 		<Unit filename="CGameInterface.h" />
 		<Unit filename="CGameState.cpp" />
 		<Unit filename="CGameState.cpp" />
 		<Unit filename="CGameState.h" />
 		<Unit filename="CGameState.h" />
+		<Unit filename="CGameStateFwd.h" />
 		<Unit filename="CGeneralTextHandler.cpp" />
 		<Unit filename="CGeneralTextHandler.cpp" />
 		<Unit filename="CGeneralTextHandler.h" />
 		<Unit filename="CGeneralTextHandler.h" />
 		<Unit filename="CHeroHandler.cpp" />
 		<Unit filename="CHeroHandler.cpp" />

+ 12 - 0
lib/logging/CLogger.cpp

@@ -119,6 +119,18 @@ void CLogger::log(ELogLevel::ELogLevel level, const std::string & message) const
 		callTargets(LogRecord(domain, level, message));
 		callTargets(LogRecord(domain, level, message));
 }
 }
 
 
+void CLogger::log(ELogLevel::ELogLevel level, const boost::format & fmt) const
+{
+	try
+	{
+		log(level, fmt.str());
+	}
+	catch(...)
+	{
+        log(ELogLevel::ERROR, "Invalid log format!");
+	}
+}
+
 ELogLevel::ELogLevel CLogger::getLevel() const
 ELogLevel::ELogLevel CLogger::getLevel() const
 {
 {
 	TLockGuard _(mx);
 	TLockGuard _(mx);

+ 1 - 0
lib/logging/CLogger.h

@@ -89,6 +89,7 @@ public:
 	CLoggerStream errorStream() const;
 	CLoggerStream errorStream() const;
 
 
 	void log(ELogLevel::ELogLevel level, const std::string & message) const override;
 	void log(ELogLevel::ELogLevel level, const std::string & message) const override;
+	void log(ELogLevel::ELogLevel level, const boost::format & fmt) const override;
 
 
 	void addTarget(std::unique_ptr<ILogTarget> && target);
 	void addTarget(std::unique_ptr<ILogTarget> && target);
 	void clearTargets();
 	void clearTargets();

+ 1 - 0
test/Test.cbp

@@ -71,6 +71,7 @@
 		</Unit>
 		</Unit>
 		<Unit filename="StdInc.h">
 		<Unit filename="StdInc.h">
 			<Option compile="1" />
 			<Option compile="1" />
+			<Option weight="0" />
 		</Unit>
 		</Unit>
 		<Extensions>
 		<Extensions>
 			<code_completion />
 			<code_completion />