Skip to content

Commit 15a4084

Browse files
committed
misc: avoid using namespace spdlog;
1 parent b902486 commit 15a4084

5 files changed

Lines changed: 15 additions & 17 deletions

File tree

include/util.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ template <typename... Args>
202202
std::exit(1);
203203
}
204204

205+
template <typename... Args>
206+
inline void error(fmt::format_string<Args...> fmt, Args&&... args) noexcept
207+
{
208+
#ifdef _WIN32
209+
MessageBox(nullptr,
210+
fmt::format(fmt::runtime(fmt), std::forward<Args>(args)...).c_str(),
211+
"Error",
212+
MB_ICONERROR | MB_OK);
213+
#endif
214+
spdlog::error(fmt, args...);
215+
}
216+
205217
template <typename... Args>
206218
inline void warn(fmt::format_string<Args...> fmt, Args&&... args) noexcept
207219
{

src/main_tool_metal.mm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ void extern_glfwSwapInterval(int v)
3636

3737
GLFWwindow* window = nullptr;
3838

39-
using namespace spdlog;
40-
4139
void minimize_window()
4240
{
4341
glfwIconifyWindow(window);
@@ -191,7 +189,7 @@ int run_main_tool(const std::string& imgui_ini_path)
191189
else
192190
{
193191
if (!font.empty())
194-
::warn("Font '{}' is not found", font);
192+
warn("Font '{}' is not found", font);
195193
continue;
196194
}
197195

src/main_tool_opengl3.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
# include <X11/Xlib.h>
2121
# endif
2222

23-
using namespace spdlog;
24-
2523
GLFWwindow* window = nullptr;
2624

2725
void glfw_error_callback(int i_error, const char* description);
@@ -231,7 +229,7 @@ int run_main_tool(const std::string& imgui_ini_path)
231229
else
232230
{
233231
if (!font.empty())
234-
::warn("Font '{}' is not found", font);
232+
warn("Font '{}' is not found", font);
235233
continue;
236234
}
237235

src/screenshot_tool.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "clipboard.hpp"
2222
#include "config.hpp"
23-
#include "fmt/format.h"
2423
#include "imgui/imgui.h"
2524
#include "imgui/imgui_impl_opengl3_loader.h"
2625
#include "imgui/imgui_internal.h"
@@ -30,18 +29,11 @@
3029
#include "tool_icons.h"
3130
#include "util.hpp"
3231

33-
#if (!__has_include("version.h"))
34-
# error "version.h not found, please generate it with ./scripts/generateVersion.sh"
35-
#else
36-
# include "version.h"
37-
#endif
38-
3932
#ifndef GL_NO_ERROR
4033
# define GL_NO_ERROR 0
4134
#endif
4235

4336
using namespace std::chrono_literals;
44-
using namespace spdlog;
4537

4638
static constexpr ImVec4 k_error_color(1.0f, 0.0f, 0.0f, 1.0f);
4739
static constexpr ImVec2 origin(0, 0);

src/text_extraction.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include "screen_capture.hpp"
1515
#include "util.hpp"
1616

17-
using namespace spdlog;
18-
1917
// --------------------
2018
// OCR
2119
// --------------------
@@ -45,7 +43,7 @@ static tesseract::PageSegMode choose_psm(int w, int h)
4543
const size_t area = static_cast<size_t>(w) * h;
4644
const float aspect = (h > 0) ? static_cast<float>(w) / static_cast<float>(h) : 1.0f;
4745

48-
debug("Choosing PSM, area: {}*{}={}, aspect: {}", w, h, area, aspect);
46+
spdlog::debug("Choosing PSM, area: {}*{}={}, aspect: {}", w, h, area, aspect);
4947

5048
// Single character: tiny and roughly square
5149
if (area < 2'500 && aspect > 0.3f && aspect < 3.0f)

0 commit comments

Comments
 (0)