Skip to content
Commits on Source (5)
......@@ -66,6 +66,7 @@ option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
if(WIN32)
option(SPDLOG_WCHAR_SUPPORT "Support wchar api" OFF)
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
endif()
option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
......@@ -86,8 +87,6 @@ set(SPDLOG_SRCS
src/file_sinks.cpp
src/async.cpp)
set(SPDLOG_CFLAGS "${PROJECT_NAME}")
if (SPDLOG_BUILD_SHARED)
if(WIN32)
message(FATAL_ERROR "spdlog shared lib is not yet supported under windows")
......@@ -128,14 +127,13 @@ if(SPDLOG_FMT_EXTERNAL)
if (NOT TARGET fmt::fmt)
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)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FMT_EXTERNAL)
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt)
set(PKG_CONFIG_REQUIRES fmt) # add dependecy to pkg-config
endif()
if(SPDLOG_WCHAR_SUPPORT)
......@@ -143,6 +141,11 @@ if(SPDLOG_WCHAR_SUPPORT)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_TO_UTF8_SUPPORT)
endif()
if(SPDLOG_WCHAR_FILENAMES)
target_compile_definitions(spdlog PUBLIC SPDLOG_WCHAR_FILENAMES)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_FILENAMES)
endif()
if(SPDLOG_NO_EXCEPTIONS)
target_compile_definitions(spdlog PUBLIC SPDLOG_NO_EXCEPTIONS)
......@@ -190,7 +193,7 @@ if (SPDLOG_INSTALL)
# Include files
#---------------------------------------------------------------------------------------
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" PATTERN "fmt/bundled" EXCLUDE)
install(TARGETS spdlog spdlog_header_only EXPORT spdlog DESTINATION "${CMAKE_INSTALL_LIBDIR}/spdlog")
install(TARGETS spdlog spdlog_header_only EXPORT spdlog DESTINATION "${CMAKE_INSTALL_LIBDIR}")
if(NOT SPDLOG_FMT_EXTERNAL)
install(DIRECTORY include/${PROJECT_NAME}/fmt/bundled/
......@@ -198,11 +201,17 @@ if (SPDLOG_INSTALL)
endif()
#---------------------------------------------------------------------------------------
# Package and version files
# Install pkg-config file
#---------------------------------------------------------------------------------------
get_target_property(PKG_CONFIG_DEFINES spdlog INTERFACE_COMPILE_DEFINITIONS)
string(REPLACE ";" " -D" PKG_CONFIG_DEFINES "${PKG_CONFIG_DEFINES}")
string(CONCAT PKG_CONFIG_DEFINES "-D" "${PKG_CONFIG_DEFINES}")
configure_file("cmake/${PROJECT_NAME}.pc.in" "${pkg_config}" @ONLY)
install(FILES "${pkg_config}" DESTINATION "${pkgconfig_install_dir}")
#---------------------------------------------------------------------------------------
# Install CMake config files
#---------------------------------------------------------------------------------------
install(EXPORT spdlog
DESTINATION ${export_dest_dir}
NAMESPACE spdlog::
......@@ -210,6 +219,7 @@ if (SPDLOG_INSTALL)
include(CMakePackageConfigHelpers)
configure_file("${project_config_in}" "${project_config_out}" @ONLY)
write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion)
install(FILES
"${project_config_out}"
......@@ -221,3 +231,4 @@ if (SPDLOG_INSTALL)
include(cmake/spdlogCPack.cmake)
endif ()
......@@ -8,7 +8,7 @@ Very fast, header-only/compiled, C++ logging library. [![Build Status](https://t
#### Header only version
Copy the source [folder](https://github.com/gabime/spdlog/tree/v1.x/include/spdlog) to your build tree and use a C++11 compiler.
#### Static lib version (recommended - much faster compile times, v1.4.0)
#### Static lib version (recommended - much faster compile times)
```console
$ git clone https://github.com/gabime/spdlog.git
$ cd spdlog && mkdir build && cd build
......
......@@ -7,5 +7,7 @@ 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@
CFlags: -I${includedir} @PKG_CONFIG_DEFINES@
Libs: -L${libdir} -lspdlog -pthread
Requires: @PKG_CONFIG_REQUIRES@
......@@ -14,6 +14,7 @@ set(CPACK_INSTALL_CMAKE_PROJECTS
set(CPACK_PROJECT_URL "https://github.com/gabime/spdlog")
set(CPACK_PACKAGE_VENDOR "Gabi Melman")
set(CPACK_PACKAGE_CONTACT "Gabi Melman <gmelman1@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Fast C++ logging library")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
......@@ -23,4 +24,9 @@ if (PROJECT_VERSION_TWEAK)
endif ()
set(CPACK_PACKAGE_RELOCATABLE ON)
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_GROUP "System Environment/Libraries")
set(CPACK_RPM_PACKAGE_URL ${CPACK_PROJECT_URL})
set(CPACK_RPM_PACKAGE_DESCRIPTION "Very fast, header-only/compiled, C++ logging library.")
include(CPack)
spdlog (1:1.4.1-1) UNRELEASED; urgency=medium
spdlog (1:1.4.2-1) UNRELEASED; urgency=medium
* New upstream version
* debhelper-compat 12
* Standards-Version: 4.4.0
* Set upstream metadata fields: Name.
* New upstream version
* Set upstream metadata fields: Repository.
* Remove obsolete fields Name from debian/upstream/metadata.
-- Michael R. Crusoe <michael.crusoe@gmail.com> Fri, 27 Sep 2019 18:43:37 +0200
-- Michael R. Crusoe <michael.crusoe@gmail.com> Wed, 06 Nov 2019 18:04:05 +0100
spdlog (1:1.3.1-1) unstable; urgency=medium
......
Name: spdlog
Repository: https://github.com/gabime/spdlog
......@@ -101,14 +101,13 @@ using sink_ptr = std::shared_ptr<sinks::sink>;
using sinks_init_list = std::initializer_list<sink_ptr>;
using err_handler = std::function<void(const std::string &err_msg)>;
using string_view_t = fmt::basic_string_view<char>;
using wstring_view_t = fmt::basic_string_view<wchar_t>;
using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
#ifndef _WIN32
#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
#else
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>
{};
......
......@@ -878,7 +878,7 @@ public:
void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override
{
auto delta = std::max(msg.time - last_message_time_, log_clock::duration::zero());
auto delta = (std::max)(msg.time - last_message_time_, log_clock::duration::zero());
auto delta_units = std::chrono::duration_cast<DurationUnits>(delta);
last_message_time_ = msg.time;
ScopedPadder p(6, padinfo_, dest);
......
......@@ -205,7 +205,7 @@ SPDLOG_INLINE void logger::dump_backtrace_()
if (tracer_)
{
sink_it_(log_msg{name(), level::info, "****************** Backtrace Start ******************"});
tracer_.foreach_pop([this](const details::log_msg &msg) { this->sink_it_(msg); });
tracer_.foreach_pop([this](const log_msg &msg) { this->sink_it_(msg); });
sink_it_(log_msg{name(), level::info, "****************** Backtrace End ********************"});
}
}
......@@ -218,7 +218,6 @@ SPDLOG_INLINE bool logger::should_flush_(const details::log_msg &msg)
SPDLOG_INLINE void logger::err_handler_(const std::string &msg)
{
if (custom_err_handler_)
{
custom_err_handler_(msg);
......
......@@ -3,8 +3,7 @@
#pragma once
// Thread safe logger (except for set_pattern(..), set_formatter(..) and
// set_error_handler())
// Thread safe logger (except for set_error_handler())
// Has name, log level, vector of std::shared sink pointers and formatter
// Upon each log write the logger:
// 1. Checks if its log level is enough to log the message and if yes:
......
......@@ -140,6 +140,10 @@ void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::print_range_(const memory_buf_t
template<typename ConsoleMutex>
void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::write_to_file_(const memory_buf_t &formatted)
{
if (out_handle_ == nullptr) // no console and no file redirect
{
return;
}
auto size = static_cast<DWORD>(formatted.size());
if (size == 0)
{
......
......@@ -5,6 +5,6 @@
#define SPDLOG_VER_MAJOR 1
#define SPDLOG_VER_MINOR 4
#define SPDLOG_VER_PATCH 1
#define SPDLOG_VER_PATCH 2
#define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH)