Use relative includes and create spdlog_config.h

This commit is contained in:
gabime 2024-01-12 17:33:23 +02:00
parent feaab0dd9f
commit 24fe442d03
47 changed files with 105 additions and 192 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
# Auto generated files
include/spdlog/spdlog_config.h
[Dd]ebug/
[Rr]elease/
build/*

View File

@ -176,7 +176,6 @@ set(SPDLOG_HEADERS
"include/spdlog/source_loc.h"
"include/spdlog/spdlog.h"
"include/spdlog/stopwatch.h"
"include/spdlog/tweakme.h"
"include/spdlog/version.h"
"include/spdlog/cfg/argv.h"
"include/spdlog/cfg/env.h"
@ -250,6 +249,11 @@ set(SPDLOG_SRCS
"src/sinks/stdout_sinks.cpp"
"src/sinks/wincolor_sink.cpp")
# Generate spdlog_config.h based on the current configuration
set(OUT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/spdlog/spdlog_config.h")
message(STATUS "Generating ${OUT_CONFIG_FILE}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/spdlog_config.h.in" ${OUT_CONFIG_FILE} @ONLY)
list(APPEND SPDLOG_HEADERS ${OUT_CONFIG_FILE})
if(BUILD_SHARED_LIBS)
if(WIN32)
@ -299,23 +303,6 @@ if(ANDROID)
target_link_libraries(spdlog PUBLIC log)
endif()
# ---------------------------------------------------------------------------------------
# Misc definitions according to tweak options
# ---------------------------------------------------------------------------------------
foreach(
SPDLOG_OPTION
SPDLOG_WCHAR_FILENAMES
SPDLOG_NO_EXCEPTIONS
SPDLOG_CLOCK_COARSE
SPDLOG_PREVENT_CHILD_FD
SPDLOG_NO_THREAD_ID
SPDLOG_NO_ATOMIC_LEVELS
SPDLOG_DISABLE_DEFAULT_LOGGER
SPDLOG_USE_STD_FORMAT)
if(${SPDLOG_OPTION})
target_compile_definitions(spdlog PUBLIC ${SPDLOG_OPTION})
endif()
endforeach()
# ---------------------------------------------------------------------------------------
# If exceptions are disabled, disable them in the bundled fmt as well
@ -407,4 +394,9 @@ if(SPDLOG_INSTALL)
# Support creation of installable packages
# ---------------------------------------------------------------------------------------
include(cmake/spdlogCPack.cmake)
# Install spdlog_config.h file
# Assume your tweakme.h.in is located in the same directory as CMakeLists.txt
set(TWEAKME_IN "${CMAKE_CURRENT_SOURCE_DIR}/tweakme.h.in")
set(TWEAKME_OUT "${CMAKE_CURRENT_BINARY_DIR}/include/spdlog/tweakme.h")
endif()

35
cmake/spdlog_config.h.in Normal file
View File

@ -0,0 +1,35 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
// Auto generated file with compile time flags with which spdlog was compiled
// DO NOT EDIT MANUALLY
#pragma once
// Support wchar filenames (Windows only)
#cmakedefine SPDLOG_WCHAR_FILENAMES
#cmakedefine SPDLOG_NO_EXCEPTIONS
// Use CLOCK_REALTIME_COARSE on Linux
#cmakedefine SPDLOG_CLOCK_COARSE
// Prevent child processes from inheriting log file descriptors
#cmakedefine SPDLOG_PREVENT_CHILD_FD
// Prevent spdlog from querying the thread id on each log call
#cmakedefine SPDLOG_NO_THREAD_ID
// Prevent spdlog from using std::atomic for log levels
#cmakedefine SPDLOG_NO_ATOMIC_LEVELS
// Disable default logger creation
#cmakedefine SPDLOG_DISABLE_DEFAULT_LOGGER
// Use std::format instead of fmtlib
#cmakedefine SPDLOG_USE_STD_FORMAT
// Use external fmtlib instead of bundled
#cmakedefine SPDLOG_FMT_EXTERNAL

View File

@ -18,9 +18,9 @@
#include <memory>
#include <mutex>
#include "async_logger.h"
#include "details/registry.h"
#include "details/thread_pool.h"
#include "./async_logger.h"
#include "./details/registry.h"
#include "./details/thread_pool.h"
namespace spdlog {

View File

@ -14,7 +14,7 @@
// Upon destruction, logs all remaining messages in the queue before
// destructing
#include "logger.h"
#include "./logger.h"
namespace spdlog {

View File

@ -3,7 +3,7 @@
#pragma once
#include "../details/registry.h"
#include "helpers.h"
#include "./helpers.h"
//
// Init log levels using each argv entry that starts with "SPDLOG_LEVEL="

View File

@ -4,7 +4,7 @@
#pragma once
#include "../details/os.h"
#include "../details/registry.h"
#include "helpers.h"
#include "./helpers.h"
//
// Init levels and patterns from env variables SPDLOG_LEVEL

View File

@ -15,8 +15,9 @@
#include <string>
#include <type_traits>
#include "source_loc.h"
#include "tweakme.h"
#include "./spdlog_config.h"
#include "./source_loc.h"
#if __has_include(<version>)
#include <version>

View File

@ -3,7 +3,7 @@
#pragma once
#include "log_msg.h"
#include "./log_msg.h"
namespace spdlog {
namespace details {

View File

@ -14,7 +14,7 @@
#include <condition_variable>
#include <mutex>
#include "circular_q.h"
#include "./circular_q.h"
namespace spdlog {
namespace details {

View File

@ -16,7 +16,7 @@
#include <unordered_map>
#include "../common.h"
#include "periodic_worker.h"
#include "./periodic_worker.h"
namespace spdlog {
class logger;

View File

@ -3,7 +3,7 @@
#pragma once
#include "registry.h"
#include "./registry.h"
namespace spdlog {

View File

@ -14,7 +14,7 @@
#include <string>
#include "../common.h"
#include "os.h"
#include "./os.h"
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "Mswsock.lib")

View File

@ -19,7 +19,7 @@
#include <string>
#include "../common.h"
#include "os.h"
#include "./os.h"
namespace spdlog {
namespace details {

View File

@ -10,9 +10,9 @@
#include <vector>
#include "../async.h"
#include "log_msg_buffer.h"
#include "mpmc_blocking_q.h"
#include "os.h"
#include "./log_msg_buffer.h"
#include "./mpmc_blocking_q.h"
#include "./os.h"
namespace spdlog {
class async_logger;

View File

@ -14,8 +14,8 @@
#include <string>
#include "../common.h"
#include "os.h"
#include "windows_include.h"
#include "./os.h"
#include "./windows_include.h"
#if defined(_MSC_VER)
#pragma comment(lib, "Ws2_32.lib")

View File

@ -7,7 +7,7 @@
// Will throw on construction if the socket creation failed.
#include "../common.h"
#include "os.h"
#include "./os.h"
#ifdef _WIN32
#error "include udp_client-windows.h instead"

View File

@ -9,7 +9,7 @@
// Include a bundled header-only copy of fmtlib or an external one.
// By default, spdlog include its own copy.
//
#include <spdlog/tweakme.h>
#include "../spdlog_config.h"
#if defined(SPDLOG_USE_STD_FORMAT) // use std::format
#include <format>

View File

@ -3,7 +3,7 @@
#pragma once
#include "details/log_msg.h"
#include "./details/log_msg.h"
#include "fmt/fmt.h"
namespace spdlog {

View File

@ -17,9 +17,9 @@
#include <cassert>
#include <vector>
#include "common.h"
#include "details/log_msg.h"
#include "sinks/sink.h"
#include "./common.h"
#include "./details/log_msg.h"
#include "./sinks/sink.h"
#ifndef SPDLOG_NO_EXCEPTIONS
#define SPDLOG_LOGGER_CATCH(location) \

View File

@ -10,10 +10,10 @@
#include <unordered_map>
#include <vector>
#include "common.h"
#include "details/log_msg.h"
#include "details/os.h"
#include "formatter.h"
#include "./common.h"
#include "./details/log_msg.h"
#include "./details/os.h"
#include "./formatter.h"
namespace spdlog {
namespace details {

View File

@ -16,8 +16,8 @@
#include "../details/fmt_helper.h"
#include "../details/null_mutex.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "os.h"
#include "./base_sink.h"
#include "./os.h"
#if !defined(SPDLOG_ANDROID_RETRIES)
#define SPDLOG_ANDROID_RETRIES 2

View File

@ -9,7 +9,7 @@
#include <string>
#include "../details/null_mutex.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -11,7 +11,7 @@
#include "../common.h"
#include "../details/log_msg.h"
#include "sink.h"
#include "./sink.h"
namespace spdlog {
namespace sinks {

View File

@ -9,7 +9,7 @@
#include "../details/file_helper.h"
#include "../details/null_mutex.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -8,7 +8,7 @@
#include "../details/null_mutex.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {

View File

@ -16,8 +16,9 @@
#include "../details/null_mutex.h"
#include "../details/os.h"
#include "../details/synchronous_factory.h"
#include "./base_sink.h"
#include "fmt/chrono.h"
#include "base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -11,7 +11,7 @@
#include "../details/log_msg.h"
#include "../details/null_mutex.h"
#include "../pattern_formatter.h"
#include "base_sink.h"
#include "./base_sink.h"
// Distribution sink (mux). Stores a vector of sinks which get called when log
// is called

View File

@ -10,7 +10,7 @@
#include "../details/log_msg.h"
#include "../details/null_mutex.h"
#include "dist_sink.h"
#include "./dist_sink.h"
// Duplicate message removal sink.
// Skip the message if previous one is identical and less than "max_skip_duration" have passed

View File

@ -16,7 +16,7 @@
#include "../details/os.h"
#include "../details/synchronous_factory.h"
#include "../fmt/fmt.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -17,7 +17,7 @@
#include "../details/log_msg.h"
#include "../details/null_mutex.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
// kafka header
#include <librdkafka/rdkafkacpp.h>

View File

@ -20,7 +20,7 @@
#include "../common.h"
#include "../details/log_msg.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -7,7 +7,7 @@
#include <string>
#include "../details/null_mutex.h"
#include "base_sink.h"
#include "./base_sink.h"
// Avoid including windows.h (https://stackoverflow.com/a/30741042)
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char *lpOutputString);

View File

@ -7,7 +7,7 @@
#include "../details/null_mutex.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -7,7 +7,7 @@
#include <ostream>
#include "../details/null_mutex.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -18,7 +18,7 @@
#include "../common.h"
#include "../details/log_msg.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
//
// qt_sink class

View File

@ -11,7 +11,7 @@
#include "../details/circular_q.h"
#include "../details/log_msg_buffer.h"
#include "../details/null_mutex.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -10,7 +10,7 @@
#include "../details/file_helper.h"
#include "../details/null_mutex.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -4,9 +4,9 @@
#pragma once
#ifdef _WIN32
#include "wincolor_sink.h"
#include "./wincolor_sink.h"
#else
#include "ansicolor_sink.h"
#include "./ansicolor_sink.h"
#endif
#include "../async.h"

View File

@ -7,8 +7,8 @@
#include "../details/synchronous_factory.h"
#include "../details/null_mutex.h"
#include "base_sink.h"
#include "sink.h"
#include "./base_sink.h"
#include "./sink.h"
#ifdef _WIN32
#include "../details/windows_include.h"

View File

@ -10,7 +10,7 @@
#include "../details/null_mutex.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -8,7 +8,7 @@
#include "../details/null_mutex.h"
#include "../details/os.h"
#include "../details/synchronous_factory.h"
#include "base_sink.h"
#include "./base_sink.h"
#ifndef SD_JOURNAL_SUPPRESS_LOCATION
#define SD_JOURNAL_SUPPRESS_LOCATION
#endif

View File

@ -5,7 +5,7 @@
#include "../common.h"
#include "../details/null_mutex.h"
#include "base_sink.h"
#include "./base_sink.h"
#ifdef _WIN32
#include "../details/tcp_client-windows.h"
#else

View File

@ -5,7 +5,7 @@
#include "../common.h"
#include "../details/null_mutex.h"
#include "base_sink.h"
#include "./base_sink.h"
#ifdef _WIN32
#include "../details/udp_client-windows.h"
#else

View File

@ -34,7 +34,7 @@ Windows Registry Editor Version 5.00
#pragma once
// clang-format off
#include "base_sink.h"
#include "./base_sink.h"
#include "../details/null_mutex.h"
#include "../details/windows_include.h"

View File

@ -11,7 +11,7 @@
#include "../common.h"
#include "../details/null_mutex.h"
#include "base_sink.h"
#include "./base_sink.h"
namespace spdlog {
namespace sinks {

View File

@ -1,117 +0,0 @@
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
///////////////////////////////////////////////////////////////////////////////
//
// Edit this file to squeeze more performance, and to customize supported
// features
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Under Linux, the much faster CLOCK_REALTIME_COARSE clock can be used.
// This clock is less accurate - can be off by dozens of millis - depending on
// the kernel HZ.
// Uncomment to use it instead of the regular clock.
//
// #define SPDLOG_CLOCK_COARSE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if source location logging is needed./
// #define SPDLOG_SOURCE_LOCATION
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if thread id logging is not needed (i.e. no %t in the log pattern).
// This will prevent spdlog from querying the thread id on each log call.
//
// WARNING: If the log pattern contains thread id (i.e, %t) while this flag is
// on, zero will be logged as thread id.
//
// #define SPDLOG_NO_THREAD_ID
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to avoid spdlog's usage of atomic log levels
// Use only if your code never modifies a logger's log levels concurrently by
// different threads.
//
// #define SPDLOG_NO_ATOMIC_LEVELS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable usage of wchar_t for file names on Windows.
//
// #define SPDLOG_WCHAR_FILENAMES
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to override default eol ("\n" or "\r\n" under Linux/Windows)
//
// #define SPDLOG_EOL ";-)\n"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to override default folder separators ("/" or "\\/" under
// Linux/Windows). Each character in the string is treated as a different
// separator.
//
// #define SPDLOG_FOLDER_SEPS "\\"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to use C++20 std::format instead of fmt.
//
// #define SPDLOG_USE_STD_FORMAT
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to prevent child processes from inheriting log file descriptors
//
// #define SPDLOG_PREVENT_CHILD_FD
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize level names (e.g. "MY TRACE")
//
// #define SPDLOG_LEVEL_NAMES { "MY TRACE", "MY DEBUG", "MY INFO", "MY WARNING", "MY ERROR", "MY
// CRITICAL", "OFF" }
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize short level names (e.g. "MT")
// These can be longer than one character.
//
// #define SPDLOG_SHORT_LEVEL_NAMES { "T", "D", "I", "W", "E", "C", "O" }
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to disable default logger creation.
// This might save some (very) small initialization time if no default logger is needed.
//
// #define SPDLOG_DISABLE_DEFAULT_LOGGER
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment and set to compile time level with zero cost (default is INFO).
// Macros like SPDLOG_DEBUG(..), SPDLOG_INFO(..) will expand to empty statements if not enabled
//
// #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment (and change if desired) macro to use for function names.
// This is compiler dependent.
// __PRETTY_FUNCTION__ might be nicer in clang/gcc, and __FUNCTION__ in msvc.
// Defaults to __FUNCTION__ (should work on all compilers) if not defined.
//
// #ifdef __PRETTY_FUNCTION__
// # define SPDLOG_FUNCTION __PRETTY_FUNCTION__
// #else
// # define SPDLOG_FUNCTION __FUNCTION__
// #endif
///////////////////////////////////////////////////////////////////////////////