Removed old logging system.
This commit is contained in:
parent
af9eacef37
commit
248a5c3e29
@ -68,9 +68,6 @@ void createSphereInVolume(SimpleVolume<uint8_t>& volData, float fRadius)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Show logs
|
|
||||||
setTraceStream(&(std::cout));
|
|
||||||
|
|
||||||
//Create and show the Qt OpenGL window
|
//Create and show the Qt OpenGL window
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
OpenGLWidget openGLWidget(0);
|
OpenGLWidget openGLWidget(0);
|
||||||
|
@ -83,13 +83,15 @@ freely, subject to the following restrictions:
|
|||||||
{ \
|
{ \
|
||||||
if (!(condition)) \
|
if (!(condition)) \
|
||||||
{ \
|
{ \
|
||||||
PolyVox::logFatal() << "\n"; \
|
std::stringstream ss; \
|
||||||
PolyVox::logFatal() << " PolyVox Assertion Failed!"; \
|
ss << "\n"; \
|
||||||
PolyVox::logFatal() << " ========================="; \
|
ss << " PolyVox Assertion Failed!"; \
|
||||||
PolyVox::logFatal() << " Condition: " << #condition; \
|
ss << " ========================="; \
|
||||||
PolyVox::logFatal() << " Message: " << (message); \
|
ss << " Condition: " << #condition; \
|
||||||
PolyVox::logFatal() << " Location: " << "Line " << __LINE__ << " of " << __FILE__; \
|
ss << " Message: " << (message); \
|
||||||
PolyVox::logFatal() << "\n"; \
|
ss << " Location: " << "Line " << __LINE__ << " of " << __FILE__; \
|
||||||
|
ss << "\n"; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logFatalMessage(ss.str()); \
|
||||||
POLYVOX_HALT(); \
|
POLYVOX_HALT(); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
@ -154,8 +156,10 @@ freely, subject to the following restrictions:
|
|||||||
{ \
|
{ \
|
||||||
if ((condition)) \
|
if ((condition)) \
|
||||||
{ \
|
{ \
|
||||||
PolyVox::logError() << (message); \
|
std::stringstream ss; \
|
||||||
throw type((message)); \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
||||||
|
throw type(ss.str()); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
@ -168,8 +172,10 @@ freely, subject to the following restrictions:
|
|||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
PolyVox::logError() << (message); \
|
std::stringstream ss; \
|
||||||
throw type((message)); \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
||||||
|
throw type(ss.str()); \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
|
||||||
@ -192,8 +198,10 @@ freely, subject to the following restrictions:
|
|||||||
{ \
|
{ \
|
||||||
if ((condition)) \
|
if ((condition)) \
|
||||||
{ \
|
{ \
|
||||||
PolyVox::logError() << (message); \
|
std::stringstream ss; \
|
||||||
type except = (type)((message)); \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
||||||
|
type except = (type)(ss.str()); \
|
||||||
getThrowHandler()((except), __FILE__, __LINE__); \
|
getThrowHandler()((except), __FILE__, __LINE__); \
|
||||||
} \
|
} \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
@ -207,8 +215,10 @@ freely, subject to the following restrictions:
|
|||||||
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
POLYVOX_DISABLE_MSC_WARNING(4127) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
PolyVox::logError() << (message); \
|
std::stringstream ss; \
|
||||||
type except = (type)((message)); \
|
ss << message; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logErrorMessage(ss.str()); \
|
||||||
|
type except = (type)(ss.str()); \
|
||||||
getThrowHandler()((except), __FILE__, __LINE__); \
|
getThrowHandler()((except), __FILE__, __LINE__); \
|
||||||
} while(0) \
|
} while(0) \
|
||||||
POLYVOX_MSC_WARNING_POP
|
POLYVOX_MSC_WARNING_POP
|
||||||
|
@ -74,112 +74,6 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setLogger(Logger* pLogger);
|
void setLogger(Logger* pLogger);
|
||||||
|
|
||||||
namespace Impl
|
|
||||||
{
|
|
||||||
std::ostream*& getTraceStreamInstance();
|
|
||||||
std::ostream*& getDebugStreamInstance();
|
|
||||||
std::ostream*& getInfoStreamInstance();
|
|
||||||
std::ostream*& getWarningStreamInstance();
|
|
||||||
std::ostream*& getErrorStreamInstance();
|
|
||||||
std::ostream*& getFatalStreamInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a stream which will consume all input without outputting anything.
|
|
||||||
std::ostream* getNullStream(void);
|
|
||||||
|
|
||||||
// These take pointers rather than references to emphasise that the
|
|
||||||
// user needs to keep the target alive as long as PolyVox is writing data.
|
|
||||||
void setTraceStream(std::ostream* pStream);
|
|
||||||
void setDebugStream(std::ostream* pStream);
|
|
||||||
void setInfoStream(std::ostream* pStream);
|
|
||||||
void setWarningStream(std::ostream* pStream);
|
|
||||||
void setErrorStream(std::ostream* pStream);
|
|
||||||
void setFatalStream(std::ostream* pStream);
|
|
||||||
|
|
||||||
// Automatically appending 'std::endl' as described here: http://stackoverflow.com/a/2179782
|
|
||||||
struct logTrace
|
|
||||||
{
|
|
||||||
logTrace(){}
|
|
||||||
~logTrace(){*(Impl::getTraceStreamInstance()) << std::endl;}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
logTrace &operator<<(const T &x)
|
|
||||||
{
|
|
||||||
*(Impl::getTraceStreamInstance()) << x;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Automatically appending 'std::endl' as described here: http://stackoverflow.com/a/2179782
|
|
||||||
struct logDebug
|
|
||||||
{
|
|
||||||
logDebug(){}
|
|
||||||
~logDebug(){*(Impl::getDebugStreamInstance()) << std::endl;}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
logDebug &operator<<(const T &x)
|
|
||||||
{
|
|
||||||
*(Impl::getDebugStreamInstance()) << x;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Automatically appending 'std::endl' as described here: http://stackoverflow.com/a/2179782
|
|
||||||
struct logInfo
|
|
||||||
{
|
|
||||||
logInfo(){}
|
|
||||||
~logInfo(){*(Impl::getInfoStreamInstance()) << std::endl;}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
logInfo &operator<<(const T &x)
|
|
||||||
{
|
|
||||||
*(Impl::getInfoStreamInstance()) << x;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Automatically appending 'std::endl' as described here: http://stackoverflow.com/a/2179782
|
|
||||||
struct logWarning
|
|
||||||
{
|
|
||||||
logWarning(){}
|
|
||||||
~logWarning(){*(Impl::getWarningStreamInstance()) << std::endl;}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
logWarning &operator<<(const T &x)
|
|
||||||
{
|
|
||||||
*(Impl::getWarningStreamInstance()) << x;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Automatically appending 'std::endl' as described here: http://stackoverflow.com/a/2179782
|
|
||||||
struct logError
|
|
||||||
{
|
|
||||||
logError(){}
|
|
||||||
~logError(){*(Impl::getErrorStreamInstance()) << std::endl;}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
logError &operator<<(const T &x)
|
|
||||||
{
|
|
||||||
*(Impl::getErrorStreamInstance()) << x;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Automatically appending 'std::endl' as described here: http://stackoverflow.com/a/2179782
|
|
||||||
struct logFatal
|
|
||||||
{
|
|
||||||
logFatal(){}
|
|
||||||
~logFatal(){*(Impl::getFatalStreamInstance()) << std::endl;}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
logFatal &operator<<(const T &x)
|
|
||||||
{
|
|
||||||
*(Impl::getFatalStreamInstance()) << x;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POLYVOX_LOG_TRACE_ENABLED
|
#ifdef POLYVOX_LOG_TRACE_ENABLED
|
||||||
|
@ -29,27 +29,29 @@ namespace PolyVox
|
|||||||
#ifndef POLYVOX_THROW_ENABLED
|
#ifndef POLYVOX_THROW_ENABLED
|
||||||
void defaultThrowHandler(std::exception& e, const char* file, int line)
|
void defaultThrowHandler(std::exception& e, const char* file, int line)
|
||||||
{
|
{
|
||||||
logFatal() << "\n"; \
|
std::stringstream ss; \
|
||||||
logFatal() << " PolyVox exception thrown!"; \
|
ss << "\n"; \
|
||||||
logFatal() << " ========================="; \
|
ss << " PolyVox exception thrown!"; \
|
||||||
logFatal() << " PolyVox has tried to throw an exception but it was built without support"; \
|
ss << " ========================="; \
|
||||||
logFatal() << " for exceptions. In this scenario PolyVox will call a 'throw handler'"; \
|
ss << " PolyVox has tried to throw an exception but it was built without support"; \
|
||||||
logFatal() << " and this message is being printed by the default throw handler."; \
|
ss << " for exceptions. In this scenario PolyVox will call a 'throw handler'"; \
|
||||||
logFatal() << "\n"; \
|
ss << " and this message is being printed by the default throw handler."; \
|
||||||
logFatal() << " If you don't want to enable exceptions then you should try to determine why"; \
|
ss << "\n"; \
|
||||||
logFatal() << " this exception was thrown and make sure it doesn't happen again. If it was"; \
|
ss << " If you don't want to enable exceptions then you should try to determine why"; \
|
||||||
logFatal() << " due to something like an invalid argument to a function then you should be"; \
|
ss << " this exception was thrown and make sure it doesn't happen again. If it was"; \
|
||||||
logFatal() << " able to fix it quite easily by validating parameters as appropriate. More"; \
|
ss << " due to something like an invalid argument to a function then you should be"; \
|
||||||
logFatal() << " complex exception scenarios (out of memory, etc) might be harder to fix and"; \
|
ss << " able to fix it quite easily by validating parameters as appropriate. More"; \
|
||||||
logFatal() << " you should replace this default handler with something which is more"; \
|
ss << " complex exception scenarios (out of memory, etc) might be harder to fix and"; \
|
||||||
logFatal() << " meaningful to your users."; \
|
ss << " you should replace this default handler with something which is more"; \
|
||||||
logFatal() << "\n"; \
|
ss << " meaningful to your users."; \
|
||||||
logFatal() << " Exception details"; \
|
ss << "\n"; \
|
||||||
logFatal() << " -----------------"; \
|
ss << " Exception details"; \
|
||||||
logFatal() << " Line: " << line; \
|
ss << " -----------------"; \
|
||||||
logFatal() << " File: " << file; \
|
ss << " Line: " << line; \
|
||||||
logFatal() << " Message: " << e.what(); \
|
ss << " File: " << file; \
|
||||||
logFatal() << "\n"; \
|
ss << " Message: " << e.what(); \
|
||||||
|
ss << "\n"; \
|
||||||
|
PolyVox::Impl::getLoggerInstance()->logFatalMessage(ss.str()); \
|
||||||
POLYVOX_HALT(); \
|
POLYVOX_HALT(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,92 +40,4 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
Impl::getLoggerInstance() = pLogger;
|
Impl::getLoggerInstance() = pLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \return A pointer to the null stream.
|
|
||||||
*/
|
|
||||||
std::ostream* getNullStream(void)
|
|
||||||
{
|
|
||||||
// Passing zero to the stream constructor guarentees it will discard all input. See
|
|
||||||
// here http://stackoverflow.com/a/8244052 and here http://stackoverflow.com/a/6240980
|
|
||||||
static std::ostream s_NullStream(0);
|
|
||||||
return &s_NullStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
// These create the global stream instances, created on demand.
|
|
||||||
namespace Impl
|
|
||||||
{
|
|
||||||
std::ostream*& getTraceStreamInstance()
|
|
||||||
{
|
|
||||||
static std::ostream* s_pTraceStream = getNullStream();
|
|
||||||
return s_pTraceStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream*& getDebugStreamInstance()
|
|
||||||
{
|
|
||||||
static std::ostream* s_pDebugStream = getNullStream();
|
|
||||||
return s_pDebugStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream*& getInfoStreamInstance()
|
|
||||||
{
|
|
||||||
static std::ostream* s_pInfoStream = &(std::cout);
|
|
||||||
return s_pInfoStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream*& getWarningStreamInstance()
|
|
||||||
{
|
|
||||||
static std::ostream* s_pWarningStream = &(std::cerr);
|
|
||||||
return s_pWarningStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream*& getErrorStreamInstance()
|
|
||||||
{
|
|
||||||
static std::ostream* s_pErrorStream = &(std::cerr);
|
|
||||||
return s_pErrorStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream*& getFatalStreamInstance()
|
|
||||||
{
|
|
||||||
static std::ostream* s_pFatalStream = &(std::cerr);
|
|
||||||
return s_pFatalStream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTraceStream(std::ostream* pStream)
|
|
||||||
{
|
|
||||||
Impl::getTraceStreamInstance() = pStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDebugStream(std::ostream* pStream)
|
|
||||||
{
|
|
||||||
Impl::getDebugStreamInstance() = pStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setInfoStream(std::ostream* pStream)
|
|
||||||
{
|
|
||||||
Impl::getInfoStreamInstance() = pStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setWarningStream(std::ostream* pStream)
|
|
||||||
{
|
|
||||||
Impl::getWarningStreamInstance() = pStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setErrorStream(std::ostream* pStream)
|
|
||||||
{
|
|
||||||
Impl::getErrorStreamInstance() = pStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fatal stream for logging
|
|
||||||
std::ostream*& getFatalStreamInstance()
|
|
||||||
{
|
|
||||||
static std::ostream* s_pFatalStream = &(std::cerr);
|
|
||||||
return s_pFatalStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFatalStream(std::ostream* pStream)
|
|
||||||
{
|
|
||||||
getFatalStreamInstance() = pStream;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user