aws / aws-iot-device-sdk-cpp

SDK for connecting to AWS IoT from a device using C++
http://aws-iot-device-sdk-cpp-docs.s3-website-us-east-1.amazonaws.com
Apache License 2.0
122 stars 111 forks source link

FormattedLogSystem creates two-line logs #138

Closed jimmylomro closed 4 years ago

jimmylomro commented 5 years ago

In the CreateLogPrefixLine: char *time = std::ctime(&time_now); if (nullptr != time) { ss << time << ":" << now_ms.count() % 1000 << " "; } time is a null terminated string and this character (null) also gets printed to ss creating a new line in the logs (only tried in osx and ubuntu). Probably a good idea wrapping it in a higher level string object would resolve this issue. String time(std::ctime(&time_now));

jimmylomro commented 5 years ago

Just realised String time(std::ctime(&time_now)) will crash when ctime returns nullptr, creating a String and poping the last character will remove the trailing new-line character: char *time = std::ctime(&time_now); if (nullptr != time) { util::String time_str(time); time_str.pop_back(); ss << time_str << ":" << now_ms.count() % 1000 << " "; }

github-actions[bot] commented 4 years ago

Greetings! Sorry to say but this is a very old issue that is probably not getting as much attention as it deservers. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to open a new one.