Fixes #149
This commit is contained in:
parent
e1c17409d9
commit
be9d0a61f4
@ -78,9 +78,9 @@ int ServiceInterfaceBuffer::sync(void) {
|
||||
}
|
||||
|
||||
size_t preambleSize = 0;
|
||||
auto preamble = getPreamble(&preambleSize);
|
||||
std::string* preamble = getPreamble(&preambleSize);
|
||||
// Write logMessage and time
|
||||
this->putChars(preamble.data(), preamble.data() + preambleSize);
|
||||
this->putChars(preamble->data(), preamble->data() + preambleSize);
|
||||
// Handle output
|
||||
this->putChars(pbase(), pptr());
|
||||
// This tells that buffer is empty again
|
||||
@ -92,7 +92,7 @@ bool ServiceInterfaceBuffer::isBuffered() const {
|
||||
return buffered;
|
||||
}
|
||||
|
||||
std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
||||
std::string* ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
||||
Clock::TimeOfDay_t loggerTime;
|
||||
Clock::getDateAndTime(&loggerTime);
|
||||
size_t currentSize = 0;
|
||||
@ -110,18 +110,18 @@ std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
||||
loggerTime.usecond /1000);
|
||||
if(charCount < 0) {
|
||||
printf("ServiceInterfaceBuffer: Failure parsing preamble\r\n");
|
||||
return "";
|
||||
return &preamble;
|
||||
}
|
||||
if(charCount > MAX_PREAMBLE_SIZE) {
|
||||
printf("ServiceInterfaceBuffer: Char count too large for maximum "
|
||||
"preamble size");
|
||||
return "";
|
||||
return &preamble;
|
||||
}
|
||||
currentSize += charCount;
|
||||
if(preambleSize != nullptr) {
|
||||
*preambleSize = currentSize;
|
||||
}
|
||||
return preamble;
|
||||
return &preamble;
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
//! In this function, the characters are parsed.
|
||||
void putChars(char const* begin, char const* end);
|
||||
|
||||
std::string getPreamble(size_t * preambleSize = nullptr);
|
||||
std::string* getPreamble(size_t * preambleSize = nullptr);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -9,7 +9,7 @@ void ServiceInterfaceStream::setActive( bool myActive) {
|
||||
this->streambuf.isActive = myActive;
|
||||
}
|
||||
|
||||
std::string ServiceInterfaceStream::getPreamble() {
|
||||
std::string* ServiceInterfaceStream::getPreamble() {
|
||||
return streambuf.getPreamble();
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
* the unbuffered mode.
|
||||
* @return Preamle consisting of log message and timestamp.
|
||||
*/
|
||||
std::string getPreamble();
|
||||
std::string* getPreamble();
|
||||
|
||||
/**
|
||||
* This prints an error with a preamble. Useful if using the unbuffered
|
||||
|
Loading…
Reference in New Issue
Block a user