mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 01:29:35 +08:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
453be2e08a | ||
![]() |
83497e4dc9 | ||
![]() |
3806a9c320 | ||
![]() |
4da95066a0 | ||
![]() |
ab1105524f | ||
![]() |
d70b743e03 | ||
![]() |
920dd078f3 | ||
![]() |
f8e780b9dd | ||
![]() |
588910129c | ||
![]() |
e42867f0a8 | ||
![]() |
fe20afac17 |
@@ -86,6 +86,7 @@ set(SPDLOG_SRCS
|
||||
src/file_sinks.cpp
|
||||
src/async.cpp)
|
||||
|
||||
set(SPDLOG_CFLAGS "${PROJECT_NAME}")
|
||||
|
||||
if (SPDLOG_BUILD_SHARED)
|
||||
if(WIN32)
|
||||
@@ -128,6 +129,8 @@ if(SPDLOG_FMT_EXTERNAL)
|
||||
find_package(fmt REQUIRED)
|
||||
endif ()
|
||||
|
||||
set(SPDLOG_CFLAGS "${SPDLOG_CFLAGS} -DSPDLOG_FMT_EXTERNAL")
|
||||
|
||||
target_compile_definitions(spdlog PUBLIC SPDLOG_FMT_EXTERNAL)
|
||||
target_link_libraries(spdlog PUBLIC fmt::fmt)
|
||||
|
||||
@@ -180,16 +183,26 @@ if (SPDLOG_INSTALL)
|
||||
set(config_targets_file "spdlogConfigTargets.cmake")
|
||||
set(version_config_file "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfigVersion.cmake")
|
||||
set(export_dest_dir "${CMAKE_INSTALL_LIBDIR}/spdlog/cmake")
|
||||
set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc")
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
# Include files
|
||||
#---------------------------------------------------------------------------------------
|
||||
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" PATTERN "fmt/bundled" EXCLUDE)
|
||||
install(TARGETS spdlog spdlog_header_only EXPORT spdlog DESTINATION "${CMAKE_INSTALL_LIBDIR}/spdlog")
|
||||
|
||||
if(NOT SPDLOG_FMT_EXTERNAL)
|
||||
install(DIRECTORY include/${PROJECT_NAME}/fmt/bundled/
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/fmt/bundled/")
|
||||
endif()
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
# Package and version files
|
||||
#---------------------------------------------------------------------------------------
|
||||
configure_file("cmake/${PROJECT_NAME}.pc.in" "${pkg_config}" @ONLY)
|
||||
install(FILES "${pkg_config}" DESTINATION "${pkgconfig_install_dir}")
|
||||
|
||||
install(EXPORT spdlog
|
||||
DESTINATION ${export_dest_dir}
|
||||
NAMESPACE spdlog::
|
||||
|
@@ -26,7 +26,7 @@ build_script:
|
||||
|
||||
set PATH=C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH%
|
||||
|
||||
cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DSPDLOG_BUILD_EXAMPLE=ON -DSPDLOG_BUILD_EXAMPLE_HO=ON -DSPDLOG_BUILD_TESTS=ON -DSPDLOG_BUILD_TESTS_HO=OFF
|
||||
cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DSPDLOG_WCHAR_SUPPORT=ON -DSPDLOG_BUILD_EXAMPLE=ON -DSPDLOG_BUILD_EXAMPLE_HO=ON -DSPDLOG_BUILD_TESTS=ON -DSPDLOG_BUILD_TESTS_HO=OFF
|
||||
|
||||
cmake --build . --config %BUILD_TYPE%
|
||||
|
||||
|
11
cmake/spdlog.pc.in
Normal file
11
cmake/spdlog.pc.in
Normal file
@@ -0,0 +1,11 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
includedir=${prefix}/include
|
||||
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
|
||||
Name: lib@PROJECT_NAME@
|
||||
Description: Fast C++ logging library.
|
||||
URL: https://github.com/gabime/@PROJECT_NAME@
|
||||
Version: @SPDLOG_VERSION@
|
||||
CFlags: -I${includedir}/@SPDLOG_CFLAGS@
|
||||
Libs: -L${libdir}/@PROJECT_NAME@ -l@PROJECT_NAME@
|
@@ -107,7 +107,7 @@ using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
|
||||
#ifndef _WIN32
|
||||
#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
|
||||
#else
|
||||
using wstring_view_t = basic_string_view_t<wchar_t>;
|
||||
using wstring_view_t = fmt::basic_string_view<wchar_t>;
|
||||
|
||||
template<typename T>
|
||||
struct is_convertible_to_wstring_view : std::is_convertible<T, wstring_view_t>
|
||||
|
@@ -15,6 +15,7 @@ class log_msg_buffer : public log_msg
|
||||
{
|
||||
memory_buf_t buffer;
|
||||
void update_string_views();
|
||||
|
||||
public:
|
||||
log_msg_buffer() = default;
|
||||
explicit log_msg_buffer(const log_msg &orig_msg);
|
||||
@@ -22,7 +23,6 @@ public:
|
||||
log_msg_buffer(log_msg_buffer &&other);
|
||||
log_msg_buffer &operator=(const log_msg_buffer &other);
|
||||
log_msg_buffer &operator=(log_msg_buffer &&other);
|
||||
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
@@ -31,4 +31,3 @@ public:
|
||||
#ifdef SPDLOG_HEADER_ONLY
|
||||
#include "log_msg_buffer-inl.h"
|
||||
#endif
|
||||
|
||||
|
@@ -85,7 +85,6 @@ public:
|
||||
std::unique_lock<std::mutex> lock(queue_mutex_);
|
||||
q_.push_back(std::move(item));
|
||||
push_cv_.notify_one();
|
||||
|
||||
}
|
||||
|
||||
// try to dequeue item. if no item found. wait upto timeout and try again
|
||||
|
@@ -396,8 +396,8 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT
|
||||
#ifdef _WIN32
|
||||
return true;
|
||||
#else
|
||||
static constexpr std::array<const char *, 14> Terms = {{
|
||||
"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"}};
|
||||
static constexpr std::array<const char *, 14> Terms = {
|
||||
{"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"}};
|
||||
|
||||
const char *env_p = std::getenv("TERM");
|
||||
if (env_p == nullptr)
|
||||
@@ -424,7 +424,7 @@ SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT
|
||||
}
|
||||
|
||||
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
|
||||
SPDLOG_INLINE void wstr_to_utf8buf(basic_string_view_t<wchar_t> wstr, memory_buf_t &target)
|
||||
SPDLOG_INLINE void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target)
|
||||
{
|
||||
if (wstr.size() > static_cast<size_t>(std::numeric_limits<int>::max()))
|
||||
{
|
||||
|
@@ -86,7 +86,7 @@ bool is_color_terminal() SPDLOG_NOEXCEPT;
|
||||
bool in_terminal(FILE *file) SPDLOG_NOEXCEPT;
|
||||
|
||||
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
|
||||
void wstr_to_utf8buf(basic_string_view_t<wchar_t> wstr, memory_buf_t &target);
|
||||
void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target);
|
||||
#endif
|
||||
|
||||
} // namespace os
|
||||
|
@@ -209,8 +209,8 @@ public:
|
||||
};
|
||||
|
||||
// Full month name
|
||||
static const std::array<const char *, 12> full_months{{
|
||||
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}};
|
||||
static const std::array<const char *, 12> full_months{
|
||||
{"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}};
|
||||
|
||||
template<typename ScopedPadder>
|
||||
class B_formatter : public flag_formatter
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include "spdlog/details/log_msg.h"
|
||||
#include "spdlog/sinks/sink.h"
|
||||
|
||||
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
template<typename Mutex>
|
||||
|
@@ -5,6 +5,6 @@
|
||||
|
||||
#define SPDLOG_VER_MAJOR 1
|
||||
#define SPDLOG_VER_MINOR 4
|
||||
#define SPDLOG_VER_PATCH 0
|
||||
#define SPDLOG_VER_PATCH 1
|
||||
|
||||
#define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH)
|
||||
|
@@ -78,3 +78,21 @@ TEST_CASE("stderr_color_mt", "[stderr]")
|
||||
l->critical("Test stderr_color_mt");
|
||||
spdlog::drop_all();
|
||||
}
|
||||
|
||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
|
||||
TEST_CASE("wchar_api", "[stdout]")
|
||||
{
|
||||
auto l = spdlog::stdout_logger_st("wchar_logger");
|
||||
l->set_pattern("%+");
|
||||
l->set_level(spdlog::level::trace);
|
||||
l->trace(L"Test wchar_api");
|
||||
l->trace(L"Test wchar_api {}", L"param");
|
||||
l->trace(L"Test wchar_api {}", 1);
|
||||
l->trace(L"Test wchar_api {}", std::wstring{L"wstring param"});
|
||||
l->trace(std::wstring{L"Test wchar_api wstring"});
|
||||
SPDLOG_LOGGER_DEBUG(l, L"Test SPDLOG_LOGGER_DEBUG {}", L"param");
|
||||
spdlog::drop_all();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user