custom for >5 resources
Fork of mbedConnectorInterface by
Diff: api/Logger.cpp
- Revision:
- 5:a929d65eb385
- Parent:
- 2:853f9ecc12df
- Child:
- 16:383ad1356963
diff -r 84159d67d32d -r a929d65eb385 api/Logger.cpp --- a/api/Logger.cpp Wed Jan 28 12:11:22 2015 +0000 +++ b/api/Logger.cpp Wed Jan 28 14:43:46 2015 +0000 @@ -39,19 +39,22 @@ { } -// Log output -void Logger::log(const char *format,...) -{ +// Log the ouput to the attached serial console +void Logger::logIt(const char *format,...) +{ + // build the variable args into a string va_list args; - va_start(args,format); - if (this->m_pc != NULL) { - //this->m_pc->printf(format,args); - //this->m_pc->printf("\r\n"); - std::printf(format,args); - std::printf("\r\n"); - } else { - std::printf(format,args); - std::printf("\r\n"); - } + char buffer[LOGGER_BUFFER_LENGTH+1]; + memset(buffer,0,LOGGER_BUFFER_LENGTH+1); + va_start(args, format); + vsnprintf(buffer,LOGGER_BUFFER_LENGTH,format,args); + + // clean up... va_end(args); + + // print it... + if (this->m_pc != NULL) + this->m_pc->printf("%s",buffer); + else + std::printf("%s",buffer); }