Merge branch 'develop' into feature/cubiquity-version
This commit is contained in:
		| @@ -35,12 +35,54 @@ freely, subject to the following restrictions: | ||||
|  * PolyVox provides basic logging facilities which can be redirected by your application. | ||||
|  */ | ||||
|  | ||||
| #define LOG_DECLARATION(name) \ | ||||
| 	std::ostream& log(name)(void); \ | ||||
| 	void set(name)Stream(std::ostream& nameStream); | ||||
|  | ||||
| namespace PolyVox | ||||
| { | ||||
| 	class Logger | ||||
| 	{ | ||||
| 	public: | ||||
| 		// Passing zero to the null stream constructor guarentees it will discard all input. See | ||||
| 		// here http://stackoverflow.com/a/8244052 and here http://stackoverflow.com/a/6240980 | ||||
| 		Logger() : m_NullStream(0) {}; | ||||
| 		virtual ~Logger() {}; | ||||
|  | ||||
| 		virtual std::ostream& getTraceStream() = 0; | ||||
| 		virtual std::ostream& getDebugStream() = 0; | ||||
| 		virtual std::ostream& getInfoStream() = 0; | ||||
| 		virtual std::ostream& getWarningStream() = 0; | ||||
| 		virtual std::ostream& getErrorStream() = 0; | ||||
| 		virtual std::ostream& getFatalStream() = 0; | ||||
|  | ||||
| 	protected: | ||||
| 		std::ostream& getNullStream() | ||||
| 		{ | ||||
| 			return m_NullStream; | ||||
| 		} | ||||
|  | ||||
| 	private: | ||||
| 		std::ostream m_NullStream; | ||||
| 	}; | ||||
|  | ||||
| 	class DefaultLogger : public Logger | ||||
| 	{ | ||||
| 	public: | ||||
| 		DefaultLogger() : Logger() {} | ||||
| 		virtual ~DefaultLogger() {} | ||||
|  | ||||
| 		std::ostream& getTraceStream() { return getNullStream(); } | ||||
| 		std::ostream& getDebugStream() { return getNullStream(); } | ||||
| 		std::ostream& getInfoStream() { return (std::cout); } | ||||
| 		std::ostream& getWarningStream() { return (std::cerr); } | ||||
| 		std::ostream& getErrorStream() { return (std::cerr); } | ||||
| 		std::ostream& getFatalStream() { return (std::cerr); } | ||||
| 	}; | ||||
|  | ||||
| 	namespace Impl | ||||
| 	{ | ||||
| 		Logger*& getLoggerInstance(); | ||||
| 	} | ||||
|  | ||||
| 	void setLogger(Logger* pLogger); | ||||
|  | ||||
| 	namespace Impl | ||||
| 	{ | ||||
| 		std::ostream*& getTraceStreamInstance(); | ||||
| @@ -159,7 +201,7 @@ namespace PolyVox | ||||
| 		do \ | ||||
| 		{ \ | ||||
| 			/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 			*(PolyVox::Impl::getTraceStreamInstance()) << message << std::endl; \ | ||||
| 			(PolyVox::Impl::getLoggerInstance()->getTraceStream()) << message << std::endl; \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
|  | ||||
| @@ -174,7 +216,7 @@ namespace PolyVox | ||||
| 			if ((condition)) \ | ||||
| 			{ \ | ||||
| 				/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 				*(PolyVox::Impl::getTraceStreamInstance()) << message << std::endl; \ | ||||
| 				(PolyVox::Impl::getLoggerInstance()->getTraceStream()) << message << std::endl; \ | ||||
| 			} \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
| @@ -212,7 +254,7 @@ namespace PolyVox | ||||
| 		do \ | ||||
| 		{ \ | ||||
| 			/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 			*(PolyVox::Impl::getDebugStreamInstance()) << message << std::endl; \ | ||||
| 			(PolyVox::Impl::getLoggerInstance()->getDebugStream()) << message << std::endl; \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
|  | ||||
| @@ -227,7 +269,7 @@ namespace PolyVox | ||||
| 			if ((condition)) \ | ||||
| 			{ \ | ||||
| 				/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 				*(PolyVox::Impl::getDebugStreamInstance()) << message << std::endl; \ | ||||
| 				(PolyVox::Impl::getLoggerInstance()->getDebugStream()) << message << std::endl; \ | ||||
| 			} \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
| @@ -265,7 +307,7 @@ namespace PolyVox | ||||
| 		do \ | ||||
| 		{ \ | ||||
| 			/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 			*(PolyVox::Impl::getInfoStreamInstance()) << message << std::endl; \ | ||||
| 			(PolyVox::Impl::getLoggerInstance()->getInfoStream()) << message << std::endl; \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
|  | ||||
| @@ -280,7 +322,7 @@ namespace PolyVox | ||||
| 			if ((condition)) \ | ||||
| 			{ \ | ||||
| 				/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 				*(PolyVox::Impl::getInfoStreamInstance()) << message << std::endl; \ | ||||
| 				(PolyVox::Impl::getLoggerInstance()->getInfoStream()) << message << std::endl; \ | ||||
| 			} \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
| @@ -318,7 +360,7 @@ namespace PolyVox | ||||
| 		do \ | ||||
| 		{ \ | ||||
| 			/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 			*(PolyVox::Impl::getWarningStreamInstance()) << message << std::endl; \ | ||||
| 			(PolyVox::Impl::getLoggerInstance()->getWarningStream()) << message << std::endl; \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
|  | ||||
| @@ -333,7 +375,7 @@ namespace PolyVox | ||||
| 			if ((condition)) \ | ||||
| 			{ \ | ||||
| 				/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 				*(PolyVox::Impl::getWarningStreamInstance()) << message << std::endl; \ | ||||
| 				(PolyVox::Impl::getLoggerInstance()->getWarningStream()) << message << std::endl; \ | ||||
| 			} \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
| @@ -371,7 +413,7 @@ namespace PolyVox | ||||
| 		do \ | ||||
| 		{ \ | ||||
| 			/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 			*(PolyVox::Impl::getErrorStreamInstance()) << message << std::endl; \ | ||||
| 			(PolyVox::Impl::getLoggerInstance()->getErrorStream()) << message << std::endl; \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
|  | ||||
| @@ -386,7 +428,7 @@ namespace PolyVox | ||||
| 			if ((condition)) \ | ||||
| 			{ \ | ||||
| 				/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 				*(PolyVox::Impl::getErrorStreamInstance()) << message << std::endl; \ | ||||
| 				(PolyVox::Impl::getLoggerInstance()->getErrorStream()) << message << std::endl; \ | ||||
| 			} \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
| @@ -424,7 +466,7 @@ namespace PolyVox | ||||
| 		do \ | ||||
| 		{ \ | ||||
| 			/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 			*(PolyVox::Impl::getFatalStreamInstance()) << message << std::endl; \ | ||||
| 			(PolyVox::Impl::getLoggerInstance()->getFatalStream()) << message << std::endl; \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
|  | ||||
| @@ -439,7 +481,7 @@ namespace PolyVox | ||||
| 			if ((condition)) \ | ||||
| 			{ \ | ||||
| 				/* Appending the 'std::endl' forces the stream to be flushed. */ \ | ||||
| 				*(PolyVox::Impl::getFatalStreamInstance()) << message << std::endl; \ | ||||
| 				(PolyVox::Impl::getLoggerInstance()->getFatalStream()) << message << std::endl; \ | ||||
| 			} \ | ||||
| 		} while(0) \ | ||||
| 		POLYVOX_MSC_WARNING_POP | ||||
|   | ||||
		Reference in New Issue
	
	Block a user