Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
3355:eb18269de57f | 3359:815b81142ff7 |
---|---|
1 #include <sstream> | |
2 #include <iostream> | |
3 | |
4 namespace Orthanc | |
5 { | |
6 namespace Logging | |
7 { | |
8 | |
9 /** | |
10 std::streambuf subclass used in FunctionCallingStream | |
11 */ | |
12 template<typename T> | |
13 class FuncStreamBuf : public std::stringbuf | |
14 { | |
15 public: | |
16 FuncStreamBuf(T func) : func_(func) {} | |
17 | |
18 virtual int sync() | |
19 { | |
20 std::string text = this->str(); | |
21 const char* buf = text.c_str(); | |
22 func_(buf); | |
23 this->str(""); | |
24 return 0; | |
25 } | |
26 private: | |
27 T func_; | |
28 }; | |
29 } | |
30 } |