Stop strftime from inserting \0, stopping the console from working
This commit is contained in:
parent
cc151ad07e
commit
563fbf526b
3 changed files with 4 additions and 3 deletions
|
@ -14,6 +14,7 @@ void console::process_message(const Level level, const System system, const std:
|
||||||
date.resize(30);
|
date.resize(30);
|
||||||
|
|
||||||
std::strftime(&date[0], date.size(), "%Y-%m-%d %H:%M:%S", std::localtime(&t_c));
|
std::strftime(&date[0], date.size(), "%Y-%m-%d %H:%M:%S", std::localtime(&t_c));
|
||||||
|
utility::erase(date, '\0'); // strftime will insert \0 for us, but it's not needed here
|
||||||
|
|
||||||
std::string s = utility::format("{} {} {}: {}", date, utility::enum_to_string(system), utility::enum_to_string(level), message);
|
std::string s = utility::format("{} {} {}: {}", date, utility::enum_to_string(system), utility::enum_to_string(level), message);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace utility {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class V>
|
template<class T, class V>
|
||||||
void erase(std::vector<T>& vec, const V& t) {
|
void erase(T& vec, const V& t) {
|
||||||
vec.erase(std::remove(vec.begin(), vec.end(), t), vec.end());
|
vec.erase(std::remove(vec.begin(), vec.end(), t), vec.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1029,7 +1029,7 @@ GFXTexture* CommonEditor::generate_common_preview(Scene& scene, const Vector3 ca
|
||||||
void CommonEditor::drawConsole() {
|
void CommonEditor::drawConsole() {
|
||||||
ImGui::BeginChild("console_output", ImVec2(-1, -1), true);
|
ImGui::BeginChild("console_output", ImVec2(-1, -1), true);
|
||||||
|
|
||||||
for(auto message : console::stored_output)
|
for(const auto& message : console::stored_output)
|
||||||
ImGui::TextWrapped("%s", message.c_str());
|
ImGui::TextWrapped("%s", message.c_str());
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
Reference in a new issue