Mercurial > hg > orthanc
diff Core/LoggingUtils.h @ 3359:815b81142ff7 emscripten-logging
Enable custom logging functions to redirect to emscripten specific logging calls
in the ORTHANC_ENABLE_LOGGING_STDIO mode.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 07 May 2019 11:23:11 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/LoggingUtils.h Tue May 07 11:23:11 2019 +0200 @@ -0,0 +1,30 @@ +#include <sstream> +#include <iostream> + +namespace Orthanc +{ + namespace Logging + { + + /** + std::streambuf subclass used in FunctionCallingStream + */ + template<typename T> + class FuncStreamBuf : public std::stringbuf + { + public: + FuncStreamBuf(T func) : func_(func) {} + + virtual int sync() + { + std::string text = this->str(); + const char* buf = text.c_str(); + func_(buf); + this->str(""); + return 0; + } + private: + T func_; + }; + } +} \ No newline at end of file