Mercurial > hg > orthanc
annotate Core/LoggingUtils.h @ 3605:05872838ebf3 storage-commitment
DicomUserConnection: Opening of a connection for N-EVENT-REPORT
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 16 Jan 2020 18:26:47 +0100 |
parents | 815b81142ff7 |
children |
rev | line source |
---|---|
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 #include <sstream> |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 #include <iostream> |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 namespace Orthanc |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 namespace Logging |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 /** |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 std::streambuf subclass used in FunctionCallingStream |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 */ |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 template<typename T> |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 class FuncStreamBuf : public std::stringbuf |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 public: |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 FuncStreamBuf(T func) : func_(func) {} |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 virtual int sync() |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 std::string text = this->str(); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 const char* buf = text.c_str(); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 func_(buf); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 this->str(""); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 return 0; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 private: |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 T func_; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 }; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 } |