File indexing completed on 2025-01-18 10:17:33
0001
0002 #include <pthread.h>
0003
0004
0005
0006 #include "JStreamLog.h"
0007
0008 JStreamLog::JStreamLog(std::streambuf* buf, const char* tag) : std::ostream(new JStreamLogBuffer(buf, tag)), own_rdbuf(true)
0009 {}
0010
0011 JStreamLog::JStreamLog(const std::ostream& os, const char* tag) : std::ostream(new JStreamLogBuffer(os.rdbuf(), tag)), own_rdbuf(true)
0012 {}
0013
0014 JStreamLog::JStreamLog(const std::ostream& os, const std::string& tag) : std::ostream(new JStreamLogBuffer(os.rdbuf(), tag.c_str())), own_rdbuf(true)
0015 {}
0016
0017 JStreamLog::~JStreamLog() {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 if(own_rdbuf){
0029 std::streambuf *mybuf = rdbuf(NULL);
0030 if(mybuf!=NULL) delete mybuf;
0031 }
0032 own_rdbuf = false;
0033 }
0034
0035 std::ostream& endMsg(std::ostream& dSL) {
0036 dSL << static_cast<char>(6);
0037 dSL << std::flush;
0038 return dSL;
0039 }
0040
0041
0042
0043
0044 std::string JStreamLog::GetTag(void)
0045 {
0046 JStreamLogBuffer *b = GetJStreamLogBuffer();
0047
0048 return (b ? b->GetTag():"unknown");
0049 }
0050
0051
0052
0053
0054 bool JStreamLog::GetTimestampFlag(void)
0055 {
0056 JStreamLogBuffer *b = GetJStreamLogBuffer();
0057
0058 return (b ? b->GetTimestampFlag():false);
0059 }
0060
0061
0062
0063
0064 bool JStreamLog::GetThreadstampFlag(void)
0065 {
0066 JStreamLogBuffer *b = GetJStreamLogBuffer();
0067
0068 return (b ? b->GetThreadstampFlag():false);
0069 }
0070
0071
0072
0073
0074 void JStreamLog::SetTag(std::string tag)
0075 {
0076 JStreamLogBuffer *b = GetJStreamLogBuffer();
0077 if(b)b->SetTag(tag);
0078 }
0079
0080
0081
0082
0083 void JStreamLog::SetTimestampFlag(bool prepend_timestamp)
0084 {
0085 JStreamLogBuffer *b = GetJStreamLogBuffer();
0086 if(b)b->SetTimestampFlag(prepend_timestamp);
0087 }
0088
0089
0090
0091
0092 void JStreamLog::SetThreadstampFlag(bool prepend_threadstamp)
0093 {
0094 JStreamLogBuffer *b = GetJStreamLogBuffer();
0095 if(b)b->SetThreadstampFlag(prepend_threadstamp);
0096 }
0097
0098
0099
0100
0101 JStreamLogBuffer* JStreamLog::GetJStreamLogBuffer(void)
0102 {
0103
0104 return dynamic_cast<JStreamLogBuffer*> (rdbuf());
0105 }
0106
0107