Changed new logging system to work on strings rather than streams.
This commit is contained in:
parent
f4e03cc537
commit
af9eacef37
@ -42,24 +42,15 @@ namespace PolyVox
|
|||||||
public:
|
public:
|
||||||
// Passing zero to the null stream constructor guarentees it will discard all input. See
|
// 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
|
// here http://stackoverflow.com/a/8244052 and here http://stackoverflow.com/a/6240980
|
||||||
Logger() : m_NullStream(0) {};
|
Logger() {};
|
||||||
virtual ~Logger() {};
|
virtual ~Logger() {};
|
||||||
|
|
||||||
virtual std::ostream& getTraceStream() = 0;
|
virtual void logTraceMessage(const std::string& message) = 0;
|
||||||
virtual std::ostream& getDebugStream() = 0;
|
virtual void logDebugMessage(const std::string& message) = 0;
|
||||||
virtual std::ostream& getInfoStream() = 0;
|
virtual void logInfoMessage(const std::string& message) = 0;
|
||||||
virtual std::ostream& getWarningStream() = 0;
|
virtual void logWarningMessage(const std::string& message) = 0;
|
||||||
virtual std::ostream& getErrorStream() = 0;
|
virtual void logErrorMessage(const std::string& message) = 0;
|
||||||
virtual std::ostream& getFatalStream() = 0;
|
virtual void logFatalMessage(const std::string& message) = 0;
|
||||||
|
|
||||||
protected:
|
|
||||||
std::ostream& getNullStream()
|
|
||||||
{
|
|
||||||
return m_NullStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::ostream m_NullStream;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultLogger : public Logger
|
class DefaultLogger : public Logger
|
||||||
@ -68,12 +59,13 @@ namespace PolyVox
|
|||||||
DefaultLogger() : Logger() {}
|
DefaultLogger() : Logger() {}
|
||||||
virtual ~DefaultLogger() {}
|
virtual ~DefaultLogger() {}
|
||||||
|
|
||||||
std::ostream& getTraceStream() { return getNullStream(); }
|
// Appending the 'std::endl' forces the stream to be flushed.
|
||||||
std::ostream& getDebugStream() { return getNullStream(); }
|
void logTraceMessage(const std::string& /*message*/) { }
|
||||||
std::ostream& getInfoStream() { return (std::cout); }
|
void logDebugMessage(const std::string& /*message*/) { }
|
||||||
std::ostream& getWarningStream() { return (std::cerr); }
|
void logInfoMessage(const std::string& message) { std::cout << message << std::endl; }
|
||||||
std::ostream& getErrorStream() { return (std::cerr); }
|
void logWarningMessage(const std::string& message) { std::cerr << message << std::endl; }
|
||||||
std::ostream& getFatalStream() { return (std::cerr); }
|
void logErrorMessage(const std::string& message) { std::cerr << message << std::endl; }
|
||||||
|
void logFatalMessage(const std::string& message) { std::cerr << message << std::endl; }
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Impl
|
namespace Impl
|
||||||
@ -200,8 +192,9 @@ namespace PolyVox
|
|||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getTraceStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logTraceMessage(ss.str()); \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
|
||||||
@ -215,8 +208,9 @@ namespace PolyVox
|
|||||||
{ \
|
{ \
|
||||||
if ((condition)) \
|
if ((condition)) \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getTraceStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logTraceMessage(ss.str()); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
@ -253,8 +247,9 @@ namespace PolyVox
|
|||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getDebugStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logDebugMessage(ss.str()); \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
|
||||||
@ -268,8 +263,9 @@ namespace PolyVox
|
|||||||
{ \
|
{ \
|
||||||
if ((condition)) \
|
if ((condition)) \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getDebugStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logDebugMessage(ss.str()); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
@ -306,8 +302,9 @@ namespace PolyVox
|
|||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getInfoStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logInfoMessage(ss.str()); \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
|
||||||
@ -321,8 +318,9 @@ namespace PolyVox
|
|||||||
{ \
|
{ \
|
||||||
if ((condition)) \
|
if ((condition)) \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getInfoStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logInfoMessage(ss.str()); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
@ -359,8 +357,9 @@ namespace PolyVox
|
|||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getWarningStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logWarningMessage(ss.str()); \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
|
||||||
@ -374,8 +373,9 @@ namespace PolyVox
|
|||||||
{ \
|
{ \
|
||||||
if ((condition)) \
|
if ((condition)) \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getWarningStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logWarningMessage(ss.str()); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
@ -412,8 +412,9 @@ namespace PolyVox
|
|||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getErrorStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
|
||||||
@ -427,8 +428,9 @@ namespace PolyVox
|
|||||||
{ \
|
{ \
|
||||||
if ((condition)) \
|
if ((condition)) \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getErrorStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
@ -465,8 +467,9 @@ namespace PolyVox
|
|||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getFatalStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logFatalMessage(ss.str()); \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
|
||||||
@ -480,8 +483,9 @@ namespace PolyVox
|
|||||||
{ \
|
{ \
|
||||||
if ((condition)) \
|
if ((condition)) \
|
||||||
{ \
|
{ \
|
||||||
/* Appending the 'std::endl' forces the stream to be flushed. */ \
|
std::stringstream ss; \
|
||||||
(PolyVox::Impl::getLoggerInstance()->getFatalStream()) << message << std::endl; \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logFatalMessage(ss.str()); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user