diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 51c41623..36c58c4a 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -48,15 +47,6 @@ namespace sinks { class sink; } -#ifdef _WIN32 - // In windows, add L prefix for filename literals (e.g. L"filename.txt") - #define SPDLOG_FILENAME_T_INNER(s) L##s - #define SPDLOG_FILENAME_T(s) SPDLOG_FILENAME_T_INNER(s) -#else - #define SPDLOG_FILENAME_T(s) s -#endif - -using filename_t = std::filesystem::path; using log_clock = std::chrono::system_clock; using sink_ptr = std::shared_ptr; using sinks_init_list = std::initializer_list; @@ -146,16 +136,4 @@ private: [[noreturn]] SPDLOG_API void throw_spdlog_ex(const std::string &msg, int last_errno); [[noreturn]] SPDLOG_API void throw_spdlog_ex(std::string msg); -struct file_event_handlers { - file_event_handlers() - : before_open(nullptr), - after_open(nullptr), - before_close(nullptr), - after_close(nullptr) {} - - std::function before_open; - std::function after_open; - std::function before_close; - std::function after_close; -}; } // namespace spdlog diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index 5b027111..97677885 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -6,6 +6,7 @@ #include #include "../common.h" +#include "../file_event_handlers.h" namespace spdlog { namespace details { @@ -30,7 +31,7 @@ public: void close(); void write(const memory_buf_t &buf) const; size_t size() const; - const filename_t &filename() const; + const filename_t &filename() const; private: const int open_tries_ = 5; diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 079b2399..f6c6d445 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -6,6 +6,7 @@ #include // std::time_t #include #include "../common.h" +#include "../filename_t.h" namespace spdlog { namespace details { diff --git a/include/spdlog/file_event_handlers.h b/include/spdlog/file_event_handlers.h index 6382cf4c..4a53df7f 100644 --- a/include/spdlog/file_event_handlers.h +++ b/include/spdlog/file_event_handlers.h @@ -1,8 +1,19 @@ -// -// Created by gabi on 12/5/24. -// +#pragma once -#ifndef FILE_EVENT_HANDLERS_H -#define FILE_EVENT_HANDLERS_H +#include +#include "./filename_t.h" -#endif //FILE_EVENT_HANDLERS_H +namespace spdlog { +struct file_event_handlers { + file_event_handlers() + : before_open(nullptr), + after_open(nullptr), + before_close(nullptr), + after_close(nullptr) {} + + std::function before_open; + std::function after_open; + std::function before_close; + std::function after_close; +}; +} // namespace spdlog diff --git a/include/spdlog/filename_t.h b/include/spdlog/filename_t.h new file mode 100644 index 00000000..f8756ab3 --- /dev/null +++ b/include/spdlog/filename_t.h @@ -0,0 +1,18 @@ +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#pragma once + +#include + +#ifdef _WIN32 + // In windows, add L prefix for filename literals (e.g. L"filename.txt") + #define SPDLOG_FILENAME_T_INNER(s) L##s + #define SPDLOG_FILENAME_T(s) SPDLOG_FILENAME_T_INNER(s) +#else + #define SPDLOG_FILENAME_T(s) s +#endif + +namespace spdlog { +using filename_t = std::filesystem::path; +} // namespace spdlog