Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Jan 6, 2025
1 parent 2c5ee06 commit f0f68e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Source/3rdParty/imgui/imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,4 @@ namespace ImGui

#define IMGUI_DISABLE_OBSOLETE_KEYIO
#define IMGUI_DEFINE_MATH_OPERATORS

#define IMGUI_DEBUG_PRINTF(_FMT,...) Dora::LogErrorThreaded(Dora::sprintf(_FMT, __VA_ARGS__))
#define IMGUI_DEBUG_PRINTF(_FMT,...) Dora::LogErrorThreaded(Slice(Dora::sprintf(_FMT, __VA_ARGS__)).trimSpace().toString())
10 changes: 4 additions & 6 deletions Source/Common/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,15 @@ class Logger : public NonCopyable {
}

void log(spdlog::level::level_enum level, const std::string& msg) {
auto m = Slice(msg).trimSpace().toString();
_logger->log(level, m);
_logger->log(level, msg);
}

void logAsync(spdlog::level::level_enum level, const std::string& msg) {
auto m = Slice(msg).trimSpace().toString();
if (Singleton<AsyncThread>::isDisposed()) {
_logger->log(level, m);
_logger->log(level, msg);
} else {
_thread->run([this, level, m]() {
_logger->log(level, m);
_thread->run([this, level, msg]() {
_logger->log(level, msg);
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Common/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ std::string sprintf(const char* fmt, ...) {
va_end(args);

if (n < 0) {
// vsnprintf 失败
// vsnprintf failed
return "";
} else if (n < size) {
// 格式化后的字符串已成功放入缓冲区
// formatted string successfully placed in buffer
return std::string(buffer.data(), n);
} else {
// 缓冲区不足,需要重新分配
// buffer is not enough, need to reallocate
size = n + 1;
buffer.resize(size);

Expand Down

0 comments on commit f0f68e1

Please sign in to comment.