File indexing completed on 2025-01-18 10:01:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #pragma once
0013 #include <iostream>
0014 #include <string.h>
0015 #include <pthread.h>
0016 #include <string>
0017 #include <sstream>
0018 #include <map>
0019
0020
0021 extern pthread_mutex_t jstreamlog_mutex;
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 class JStreamLogBuffer : public std::streambuf
0033 {
0034 private:
0035 std::streambuf* __sbuf;
0036 char* __tag;
0037
0038 bool __prepend_timestamp;
0039 bool __prepend_threadstamp;
0040
0041 protected:
0042 int overflow(int c);
0043 int sync();
0044 std::string getThreadStamp();
0045 std::string getTimeStamp();
0046
0047
0048
0049 std::map<pthread_t,std::string> thr_buffers;
0050
0051 public:
0052 JStreamLogBuffer(std::streambuf* buf, const char* tag);
0053 virtual ~JStreamLogBuffer();
0054
0055 std::string GetTag(void){return std::string(__tag);}
0056 bool GetTimestampFlag(void){return __prepend_timestamp;}
0057 bool GetThreadstampFlag(void){return __prepend_threadstamp;}
0058 void SetTag(std::string tag);
0059 void SetTimestampFlag(bool prepend_timestamp=true){__prepend_timestamp=prepend_timestamp;}
0060 void SetThreadstampFlag(bool prepend_threadstamp=true){__prepend_threadstamp=prepend_threadstamp;}
0061 };
0062