diff --git a/.clang-format b/.clang-format index c8c345f6..d324138a 100644 --- a/.clang-format +++ b/.clang-format @@ -14,6 +14,6 @@ AlwaysBreakTemplateDeclarations: Yes PackConstructorInitializers: Never BreakConstructorInitializersBeforeComma: false IndentPPDirectives: BeforeHash -SortIncludes: Never +SortIncludes: CaseInsensitive ... diff --git a/bench/async_bench.cpp b/bench/async_bench.cpp index a136c7bd..e813e5a3 100644 --- a/bench/async_bench.cpp +++ b/bench/async_bench.cpp @@ -6,9 +6,9 @@ // // bench.cpp : spdlog benchmarks // -#include "spdlog/spdlog.h" #include "spdlog/async.h" #include "spdlog/sinks/basic_file_sink.h" +#include "spdlog/spdlog.h" #if defined(SPDLOG_USE_STD_FORMAT) #include @@ -18,13 +18,14 @@ #include "spdlog/fmt/bundled/format.h" #endif -#include "utils.h" #include #include #include #include #include +#include "utils.h" + using namespace std; using namespace std::chrono; using namespace spdlog; diff --git a/bench/bench.cpp b/bench/bench.cpp index d370dd63..4b838184 100644 --- a/bench/bench.cpp +++ b/bench/bench.cpp @@ -6,11 +6,11 @@ // // bench.cpp : spdlog benchmarks // -#include "spdlog/spdlog.h" #include "spdlog/sinks/basic_file_sink.h" #include "spdlog/sinks/daily_file_sink.h" #include "spdlog/sinks/null_sink.h" #include "spdlog/sinks/rotating_file_sink.h" +#include "spdlog/spdlog.h" #if defined(SPDLOG_USE_STD_FORMAT) #include @@ -20,13 +20,14 @@ #include "spdlog/fmt/bundled/format.h" #endif -#include "utils.h" #include #include // EXIT_FAILURE #include #include #include +#include "utils.h" + void bench(int howmany, std::shared_ptr log); void bench_mt(int howmany, std::shared_ptr log, size_t thread_count); diff --git a/bench/formatter-bench.cpp b/bench/formatter-bench.cpp index 8e88b92f..f79f58d2 100644 --- a/bench/formatter-bench.cpp +++ b/bench/formatter-bench.cpp @@ -4,9 +4,8 @@ // #include "benchmark/benchmark.h" - -#include "spdlog/spdlog.h" #include "spdlog/pattern_formatter.h" +#include "spdlog/spdlog.h" void bench_formatter(benchmark::State &state, std::string pattern) { auto formatter = std::make_unique(pattern); diff --git a/bench/latency.cpp b/bench/latency.cpp index 20c24dfa..a7c84777 100644 --- a/bench/latency.cpp +++ b/bench/latency.cpp @@ -8,13 +8,12 @@ // #include "benchmark/benchmark.h" - -#include "spdlog/spdlog.h" #include "spdlog/async.h" #include "spdlog/sinks/basic_file_sink.h" #include "spdlog/sinks/daily_file_sink.h" #include "spdlog/sinks/null_sink.h" #include "spdlog/sinks/rotating_file_sink.h" +#include "spdlog/spdlog.h" void bench_c_string(benchmark::State &state, std::shared_ptr logger) { const char *msg = diff --git a/example/example.cpp b/example/example.cpp index 126580a7..1b74f6d1 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -4,8 +4,8 @@ // spdlog usage example -#include #include +#include void load_levels_example(); void stdout_logger_example(); @@ -31,8 +31,8 @@ void replace_default_logger_example(); // This will add filename/line/column info to the log (and in to the resulting binary so take care). // #define SPDLOG_SOURCE_LOCATION -#include "spdlog/spdlog.h" #include "spdlog/cfg/env.h" // support for loading levels from the environment variable +#include "spdlog/spdlog.h" int main(int, char *[]) { // Log levels can be loaded from argv/env using "SPDLOG_LEVEL" @@ -220,8 +220,9 @@ void trace_example() { } // stopwatch example -#include "spdlog/stopwatch.h" #include + +#include "spdlog/stopwatch.h" void stopwatch_example() { spdlog::stopwatch sw; std::this_thread::sleep_for(std::chrono::milliseconds(123)); diff --git a/include/spdlog/async.h b/include/spdlog/async.h index 9d6bf1d8..b5814b53 100644 --- a/include/spdlog/async.h +++ b/include/spdlog/async.h @@ -14,14 +14,14 @@ // This is because each message in the queue holds a shared_ptr to the // originating logger. -#include "async_logger.h" -#include "details/registry.h" -#include "details/thread_pool.h" - #include #include #include +#include "async_logger.h" +#include "details/registry.h" +#include "details/thread_pool.h" + namespace spdlog { namespace details { diff --git a/include/spdlog/cfg/argv.h b/include/spdlog/cfg/argv.h index 19e17e3c..899a1ff8 100644 --- a/include/spdlog/cfg/argv.h +++ b/include/spdlog/cfg/argv.h @@ -2,8 +2,8 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once -#include "helpers.h" #include "../details/registry.h" +#include "helpers.h" // // Init log levels using each argv entry that starts with "SPDLOG_LEVEL=" diff --git a/include/spdlog/cfg/env.h b/include/spdlog/cfg/env.h index 777aee4e..c2fb74ba 100644 --- a/include/spdlog/cfg/env.h +++ b/include/spdlog/cfg/env.h @@ -2,9 +2,9 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once -#include "helpers.h" #include "../details/os.h" #include "../details/registry.h" +#include "helpers.h" // // Init levels and patterns from env variables SPDLOG_LEVEL diff --git a/include/spdlog/cfg/helpers.h b/include/spdlog/cfg/helpers.h index 6933d777..f928d91d 100644 --- a/include/spdlog/cfg/helpers.h +++ b/include/spdlog/cfg/helpers.h @@ -3,9 +3,10 @@ #pragma once -#include "../common.h" #include +#include "../common.h" + namespace spdlog { namespace cfg { namespace helpers { diff --git a/include/spdlog/common.h b/include/spdlog/common.h index b97ba6e5..eabe628b 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -2,9 +2,6 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once -#include "details/null_mutex.h" -#include "tweakme.h" - #include #include #include @@ -17,6 +14,9 @@ #include #include +#include "details/null_mutex.h" +#include "tweakme.h" + #if __has_include() #include #endif diff --git a/include/spdlog/details/console_globals.h b/include/spdlog/details/console_globals.h index 52a8929a..87e9c365 100644 --- a/include/spdlog/details/console_globals.h +++ b/include/spdlog/details/console_globals.h @@ -3,9 +3,10 @@ #pragma once -#include "null_mutex.h" #include +#include "null_mutex.h" + namespace spdlog { namespace details { diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index 6d406ac6..c267129c 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -3,9 +3,10 @@ #pragma once -#include "../common.h" #include +#include "../common.h" + namespace spdlog { namespace details { diff --git a/include/spdlog/details/fmt_helper.h b/include/spdlog/details/fmt_helper.h index 1786a124..11af1fb8 100644 --- a/include/spdlog/details/fmt_helper.h +++ b/include/spdlog/details/fmt_helper.h @@ -2,13 +2,13 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once -#include "../common.h" -#include "../fmt/fmt.h" - #include #include #include +#include "../common.h" +#include "../fmt/fmt.h" + #ifdef SPDLOG_USE_STD_FORMAT #include #include diff --git a/include/spdlog/details/log_msg.h b/include/spdlog/details/log_msg.h index b7f0b51d..5f439061 100644 --- a/include/spdlog/details/log_msg.h +++ b/include/spdlog/details/log_msg.h @@ -3,9 +3,10 @@ #pragma once -#include "../common.h" #include +#include "../common.h" + namespace spdlog { namespace details { struct SPDLOG_API log_msg { diff --git a/include/spdlog/details/mpmc_blocking_q.h b/include/spdlog/details/mpmc_blocking_q.h index 5ef71c1c..6d3e298f 100644 --- a/include/spdlog/details/mpmc_blocking_q.h +++ b/include/spdlog/details/mpmc_blocking_q.h @@ -10,12 +10,12 @@ // dequeue_for(..) - will block until the queue is not empty or timeout have // passed. -#include "circular_q.h" - #include #include #include +#include "circular_q.h" + namespace spdlog { namespace details { diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 16aa695d..f76edc96 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -3,9 +3,10 @@ #pragma once -#include "../common.h" #include // std::time_t +#include "../common.h" + namespace spdlog { namespace details { namespace os { diff --git a/include/spdlog/details/periodic_worker.h b/include/spdlog/details/periodic_worker.h index 767d3643..c2190d69 100644 --- a/include/spdlog/details/periodic_worker.h +++ b/include/spdlog/details/periodic_worker.h @@ -10,14 +10,14 @@ // stops and joins the thread on destruction (if the thread is executing a callback, wait for it // to finish first). -#include "../common.h" - #include #include #include #include #include +#include "../common.h" + namespace spdlog { namespace details { diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index a4b21643..c2cd7095 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -8,9 +8,6 @@ // If user requests a non existing logger, nullptr will be returned // This class is thread safe -#include "../common.h" -#include "periodic_worker.h" - #include #include #include @@ -18,6 +15,9 @@ #include #include +#include "../common.h" +#include "periodic_worker.h" + namespace spdlog { class logger; diff --git a/include/spdlog/details/tcp_client-windows.h b/include/spdlog/details/tcp_client-windows.h index b4fc626f..94614353 100644 --- a/include/spdlog/details/tcp_client-windows.h +++ b/include/spdlog/details/tcp_client-windows.h @@ -5,16 +5,17 @@ #define WIN32_LEAN_AND_MEAN // tcp client helper -#include "../common.h" -#include "os.h" - #include #include -#include #include #include #include +#include + +#include "../common.h" +#include "os.h" + #pragma comment(lib, "Ws2_32.lib") #pragma comment(lib, "Mswsock.lib") #pragma comment(lib, "AdvApi32.lib") diff --git a/include/spdlog/details/tcp_client.h b/include/spdlog/details/tcp_client.h index 93d55c21..80f9b598 100644 --- a/include/spdlog/details/tcp_client.h +++ b/include/spdlog/details/tcp_client.h @@ -8,9 +8,6 @@ #endif // tcp client helper -#include "../common.h" -#include "os.h" - #include #include #include @@ -20,6 +17,9 @@ #include +#include "../common.h" +#include "os.h" + namespace spdlog { namespace details { class tcp_client { diff --git a/include/spdlog/details/thread_pool.h b/include/spdlog/details/thread_pool.h index f94af769..643532fd 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -3,17 +3,17 @@ #pragma once -#include "../async.h" -#include "log_msg_buffer.h" -#include "mpmc_blocking_q.h" -#include "os.h" - #include #include #include #include #include +#include "../async.h" +#include "log_msg_buffer.h" +#include "mpmc_blocking_q.h" +#include "os.h" + namespace spdlog { class async_logger; diff --git a/include/spdlog/details/udp_client-windows.h b/include/spdlog/details/udp_client-windows.h index d6b6cb59..446b3a56 100644 --- a/include/spdlog/details/udp_client-windows.h +++ b/include/spdlog/details/udp_client-windows.h @@ -6,16 +6,17 @@ // Helper RAII over winsock udp client socket. // Will throw on construction if socket creation failed. -#include "os.h" -#include "windows_include.h" -#include "../common.h" - #include #include -#include #include #include +#include + +#include "../common.h" +#include "os.h" +#include "windows_include.h" + #if defined(_MSC_VER) #pragma comment(lib, "Ws2_32.lib") #pragma comment(lib, "Mswsock.lib") diff --git a/include/spdlog/details/udp_client.h b/include/spdlog/details/udp_client.h index 60bbdefa..2e3067e9 100644 --- a/include/spdlog/details/udp_client.h +++ b/include/spdlog/details/udp_client.h @@ -9,18 +9,18 @@ #include "../common.h" #include "os.h" - #ifdef _WIN32 #error "include udp_client-windows.h instead" #endif #include -#include #include #include #include #include #include + +#include #include namespace spdlog { diff --git a/include/spdlog/fmt/bin_to_hex.h b/include/spdlog/fmt/bin_to_hex.h index 376e8319..77a5bf14 100644 --- a/include/spdlog/fmt/bin_to_hex.h +++ b/include/spdlog/fmt/bin_to_hex.h @@ -6,6 +6,7 @@ #pragma once #include + #include "../common.h" #if defined(__has_include) diff --git a/include/spdlog/fmt/compile.h b/include/spdlog/fmt/compile.h index 2034f5cf..bf3a49c5 100644 --- a/include/spdlog/fmt/compile.h +++ b/include/spdlog/fmt/compile.h @@ -10,7 +10,7 @@ #if !defined(SPDLOG_USE_STD_FORMAT) #if !defined(SPDLOG_FMT_EXTERNAL) - #include "../fmt/bundled/compile.h" + #include "../fmt/bundled/compile.h" #else #include #endif diff --git a/include/spdlog/fmt/ostr.h b/include/spdlog/fmt/ostr.h index 9ee7e28a..2bb1f28d 100644 --- a/include/spdlog/fmt/ostr.h +++ b/include/spdlog/fmt/ostr.h @@ -10,7 +10,7 @@ #if !defined(SPDLOG_USE_STD_FORMAT) #if !defined(SPDLOG_FMT_EXTERNAL) - #include "../fmt/bundled/ostream.h" + #include "../fmt/bundled/ostream.h" #else #include #endif diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 0915d1ac..f733507e 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -14,13 +14,13 @@ // The use of private formatter per sink provides the opportunity to cache some // formatted data, and support for different format per sink. +#include +#include + #include "common.h" #include "details/log_msg.h" #include "sinks/sink.h" -#include -#include - #ifndef SPDLOG_NO_EXCEPTIONS #define SPDLOG_LOGGER_CATCH(location) \ catch (const std::exception &ex) { \ diff --git a/include/spdlog/pattern_formatter.h b/include/spdlog/pattern_formatter.h index 10a90c3d..53cbd732 100644 --- a/include/spdlog/pattern_formatter.h +++ b/include/spdlog/pattern_formatter.h @@ -3,19 +3,18 @@ #pragma once +#include +#include +#include +#include +#include +#include + #include "common.h" #include "details/log_msg.h" #include "details/os.h" #include "formatter.h" -#include -#include -#include - -#include -#include -#include - namespace spdlog { namespace details { diff --git a/include/spdlog/sinks/android_sink.h b/include/spdlog/sinks/android_sink.h index aa527cfc..6823a037 100644 --- a/include/spdlog/sinks/android_sink.h +++ b/include/spdlog/sinks/android_sink.h @@ -5,19 +5,20 @@ #ifdef __ANDROID__ - #include "../details/fmt_helper.h" - #include "../details/null_mutex.h" - #include "os.h" - #include "../details/synchronous_factory.h" - #include "base_sink.h" - #include + #include #include #include #include #include + #include "../details/fmt_helper.h" + #include "../details/null_mutex.h" + #include "../details/synchronous_factory.h" + #include "base_sink.h" + #include "os.h" + #if !defined(SPDLOG_ANDROID_RETRIES) #define SPDLOG_ANDROID_RETRIES 2 #endif diff --git a/include/spdlog/sinks/ansicolor_sink.h b/include/spdlog/sinks/ansicolor_sink.h index e5f5c873..110b7c19 100644 --- a/include/spdlog/sinks/ansicolor_sink.h +++ b/include/spdlog/sinks/ansicolor_sink.h @@ -6,10 +6,11 @@ #include #include #include +#include + #include "../details/console_globals.h" #include "../details/null_mutex.h" #include "sink.h" -#include namespace spdlog { namespace sinks { diff --git a/include/spdlog/sinks/basic_file_sink.h b/include/spdlog/sinks/basic_file_sink.h index 5c4a590c..d581afc7 100644 --- a/include/spdlog/sinks/basic_file_sink.h +++ b/include/spdlog/sinks/basic_file_sink.h @@ -3,14 +3,14 @@ #pragma once +#include +#include + #include "../details/file_helper.h" #include "../details/null_mutex.h" #include "../details/synchronous_factory.h" #include "base_sink.h" -#include -#include - namespace spdlog { namespace sinks { /* diff --git a/include/spdlog/sinks/callback_sink.h b/include/spdlog/sinks/callback_sink.h index cc87d741..ad0f1dc6 100644 --- a/include/spdlog/sinks/callback_sink.h +++ b/include/spdlog/sinks/callback_sink.h @@ -3,13 +3,13 @@ #pragma once +#include +#include + #include "../details/null_mutex.h" #include "../details/synchronous_factory.h" #include "base_sink.h" -#include -#include - namespace spdlog { // callbacks type diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h index 5331cc7d..2a888543 100644 --- a/include/spdlog/sinks/daily_file_sink.h +++ b/include/spdlog/sinks/daily_file_sink.h @@ -3,6 +3,13 @@ #pragma once +#include +#include +#include +#include +#include +#include + #include "../common.h" #include "../details/circular_q.h" #include "../details/file_helper.h" @@ -13,13 +20,6 @@ #include "../fmt/fmt.h" #include "base_sink.h" -#include -#include -#include -#include -#include -#include - namespace spdlog { namespace sinks { diff --git a/include/spdlog/sinks/dist_sink.h b/include/spdlog/sinks/dist_sink.h index 3d3206f1..f4c33d4c 100644 --- a/include/spdlog/sinks/dist_sink.h +++ b/include/spdlog/sinks/dist_sink.h @@ -3,16 +3,16 @@ #pragma once -#include "base_sink.h" -#include "../details/log_msg.h" -#include "../details/null_mutex.h" -#include "../pattern_formatter.h" - #include #include #include #include +#include "../details/log_msg.h" +#include "../details/null_mutex.h" +#include "../pattern_formatter.h" +#include "base_sink.h" + // Distribution sink (mux). Stores a vector of sinks which get called when log // is called diff --git a/include/spdlog/sinks/dup_filter_sink.h b/include/spdlog/sinks/dup_filter_sink.h index 12cd1c34..55a4e9c0 100644 --- a/include/spdlog/sinks/dup_filter_sink.h +++ b/include/spdlog/sinks/dup_filter_sink.h @@ -3,15 +3,15 @@ #pragma once -#include "dist_sink.h" -#include "../details/log_msg.h" -#include "../details/null_mutex.h" - #include #include #include #include +#include "../details/log_msg.h" +#include "../details/null_mutex.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 // diff --git a/include/spdlog/sinks/hourly_file_sink.h b/include/spdlog/sinks/hourly_file_sink.h index f390d7d5..4f358872 100644 --- a/include/spdlog/sinks/hourly_file_sink.h +++ b/include/spdlog/sinks/hourly_file_sink.h @@ -3,6 +3,12 @@ #pragma once +#include +#include +#include +#include +#include + #include "../common.h" #include "../details/circular_q.h" #include "../details/file_helper.h" @@ -12,12 +18,6 @@ #include "../fmt/fmt.h" #include "base_sink.h" -#include -#include -#include -#include -#include - namespace spdlog { namespace sinks { diff --git a/include/spdlog/sinks/kafka_sink.h b/include/spdlog/sinks/kafka_sink.h index 6e5020cb..03571ba3 100644 --- a/include/spdlog/sinks/kafka_sink.h +++ b/include/spdlog/sinks/kafka_sink.h @@ -10,14 +10,14 @@ // https://github.com/confluentinc/librdkafka // -#include "base_sink.h" +#include + #include "../async.h" +#include "../common.h" #include "../details/log_msg.h" #include "../details/null_mutex.h" #include "../details/synchronous_factory.h" - -#include -#include "../common.h" +#include "base_sink.h" // kafka header #include diff --git a/include/spdlog/sinks/mongo_sink.h b/include/spdlog/sinks/mongo_sink.h index b6a212a4..51b7c48e 100644 --- a/include/spdlog/sinks/mongo_sink.h +++ b/include/spdlog/sinks/mongo_sink.h @@ -10,19 +10,18 @@ // http://mongocxx.org/mongocxx-v3/installation/ // -#include "base_sink.h" -#include "../common.h" -#include "../details/log_msg.h" -#include "../details/synchronous_factory.h" - #include #include #include - #include #include #include +#include "../common.h" +#include "../details/log_msg.h" +#include "../details/synchronous_factory.h" +#include "base_sink.h" + namespace spdlog { namespace sinks { template @@ -78,8 +77,9 @@ private: std::unique_ptr client_ = nullptr; }; -#include "../details/null_mutex.h" #include + +#include "../details/null_mutex.h" using mongo_sink_mt = mongo_sink; using mongo_sink_st = mongo_sink; diff --git a/include/spdlog/sinks/msvc_sink.h b/include/spdlog/sinks/msvc_sink.h index bad0a324..6a7000fa 100644 --- a/include/spdlog/sinks/msvc_sink.h +++ b/include/spdlog/sinks/msvc_sink.h @@ -4,12 +4,12 @@ #pragma once #if defined(_WIN32) - #include "../details/null_mutex.h" - #include "base_sink.h" - #include #include + #include "../details/null_mutex.h" + #include "base_sink.h" + // Avoid including windows.h (https://stackoverflow.com/a/30741042) extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char *lpOutputString); extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); diff --git a/include/spdlog/sinks/null_sink.h b/include/spdlog/sinks/null_sink.h index fc016a45..adbaa7b5 100644 --- a/include/spdlog/sinks/null_sink.h +++ b/include/spdlog/sinks/null_sink.h @@ -3,12 +3,12 @@ #pragma once +#include + #include "../details/null_mutex.h" #include "../details/synchronous_factory.h" #include "base_sink.h" -#include - namespace spdlog { namespace sinks { diff --git a/include/spdlog/sinks/ostream_sink.h b/include/spdlog/sinks/ostream_sink.h index 041a8821..9be8a896 100644 --- a/include/spdlog/sinks/ostream_sink.h +++ b/include/spdlog/sinks/ostream_sink.h @@ -3,12 +3,12 @@ #pragma once -#include "../details/null_mutex.h" -#include "base_sink.h" - #include #include +#include "../details/null_mutex.h" +#include "base_sink.h" + namespace spdlog { namespace sinks { template diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index 6e778036..56f4b965 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -11,15 +11,15 @@ // If the widget's lifetime can be shorter than the logger's one, you should provide some permanent // QObject, and then use a standard signal/slot. // -#include "base_sink.h" -#include "../common.h" -#include "../details/log_msg.h" -#include "../details/synchronous_factory.h" - #include #include #include +#include "../common.h" +#include "../details/log_msg.h" +#include "../details/synchronous_factory.h" +#include "base_sink.h" + // // qt_sink class // @@ -224,9 +224,10 @@ protected: std::array colors_; }; -#include "../details/null_mutex.h" #include +#include "../details/null_mutex.h" + using qt_sink_mt = qt_sink; using qt_sink_st = qt_sink; using qt_color_sink_mt = qt_color_sink; diff --git a/include/spdlog/sinks/ringbuffer_sink.h b/include/spdlog/sinks/ringbuffer_sink.h index 2b64c52f..6534cf77 100644 --- a/include/spdlog/sinks/ringbuffer_sink.h +++ b/include/spdlog/sinks/ringbuffer_sink.h @@ -3,16 +3,16 @@ #pragma once -#include "base_sink.h" -#include "../details/circular_q.h" -#include "../details/log_msg_buffer.h" -#include "../details/null_mutex.h" - #include #include #include #include +#include "../details/circular_q.h" +#include "../details/log_msg_buffer.h" +#include "../details/null_mutex.h" +#include "base_sink.h" + namespace spdlog { namespace sinks { /* diff --git a/include/spdlog/sinks/rotating_file_sink.h b/include/spdlog/sinks/rotating_file_sink.h index 31eae472..dc232c8d 100644 --- a/include/spdlog/sinks/rotating_file_sink.h +++ b/include/spdlog/sinks/rotating_file_sink.h @@ -3,15 +3,15 @@ #pragma once +#include +#include +#include + #include "../details/file_helper.h" #include "../details/null_mutex.h" #include "../details/synchronous_factory.h" #include "base_sink.h" -#include -#include -#include - namespace spdlog { namespace sinks { // diff --git a/include/spdlog/sinks/stdout_sinks.h b/include/spdlog/sinks/stdout_sinks.h index 8dd59058..67b37e9c 100644 --- a/include/spdlog/sinks/stdout_sinks.h +++ b/include/spdlog/sinks/stdout_sinks.h @@ -3,12 +3,12 @@ #pragma once +#include + #include "../details/console_globals.h" #include "../details/synchronous_factory.h" #include "sink.h" -#include - #ifdef _WIN32 #include "../details/windows_include.h" #endif diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index 5b1d2818..600bb6b2 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -3,13 +3,14 @@ #pragma once -#include "../details/null_mutex.h" -#include "../details/synchronous_factory.h" -#include "base_sink.h" +#include #include #include -#include + +#include "../details/null_mutex.h" +#include "../details/synchronous_factory.h" +#include "base_sink.h" namespace spdlog { namespace sinks { diff --git a/include/spdlog/sinks/systemd_sink.h b/include/spdlog/sinks/systemd_sink.h index fcf52346..e449a1ae 100644 --- a/include/spdlog/sinks/systemd_sink.h +++ b/include/spdlog/sinks/systemd_sink.h @@ -3,12 +3,12 @@ #pragma once +#include + #include "../details/null_mutex.h" #include "../details/os.h" #include "../details/synchronous_factory.h" #include "base_sink.h" - -#include #ifndef SD_JOURNAL_SUPPRESS_LOCATION #define SD_JOURNAL_SUPPRESS_LOCATION #endif diff --git a/include/spdlog/sinks/win_eventlog_sink.h b/include/spdlog/sinks/win_eventlog_sink.h index 01b7e9c6..7c32a0f5 100644 --- a/include/spdlog/sinks/win_eventlog_sink.h +++ b/include/spdlog/sinks/win_eventlog_sink.h @@ -33,16 +33,16 @@ Windows Registry Editor Version 5.00 #pragma once -#include "../details/null_mutex.h" -#include "base_sink.h" - -#include "../details/windows_include.h" #include #include #include #include +#include "../details/null_mutex.h" +#include "../details/windows_include.h" +#include "base_sink.h" + namespace spdlog { namespace sinks { diff --git a/include/spdlog/sinks/wincolor_sink.h b/include/spdlog/sinks/wincolor_sink.h index e9b02869..b4716349 100644 --- a/include/spdlog/sinks/wincolor_sink.h +++ b/include/spdlog/sinks/wincolor_sink.h @@ -3,17 +3,17 @@ #pragma once -#include "../common.h" -#include "../details/console_globals.h" -#include "../details/null_mutex.h" -#include "sink.h" - #include #include #include #include #include +#include "../common.h" +#include "../details/console_globals.h" +#include "../details/null_mutex.h" +#include "sink.h" + namespace spdlog { namespace sinks { /* diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 8bf8e56d..8e4c2130 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -9,17 +9,17 @@ #pragma once -#include "common.h" -#include "logger.h" -#include "version.h" -#include "details/registry.h" -#include "details/synchronous_factory.h" - #include #include #include #include +#include "common.h" +#include "details/registry.h" +#include "details/synchronous_factory.h" +#include "logger.h" +#include "version.h" + namespace spdlog { using default_factory = synchronous_factory; diff --git a/include/spdlog/stopwatch.h b/include/spdlog/stopwatch.h index 966a69a6..1bdfc258 100644 --- a/include/spdlog/stopwatch.h +++ b/include/spdlog/stopwatch.h @@ -4,6 +4,7 @@ #pragma once #include + #include "fmt/fmt.h" // Stopwatch support for spdlog (using std::chrono::steady_clock). diff --git a/src/async_logger.cpp b/src/async_logger.cpp index f1f615c6..f84606b8 100644 --- a/src/async_logger.cpp +++ b/src/async_logger.cpp @@ -2,12 +2,13 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #include "spdlog/async_logger.h" -#include "spdlog/details/thread_pool.h" -#include "spdlog/sinks/sink.h" #include #include +#include "spdlog/details/thread_pool.h" +#include "spdlog/sinks/sink.h" + spdlog::async_logger::async_logger(std::string logger_name, sinks_init_list sinks_list, std::weak_ptr tp, diff --git a/src/cfg/helpers.cpp b/src/cfg/helpers.cpp index 6b498107..1e6d8983 100644 --- a/src/cfg/helpers.cpp +++ b/src/cfg/helpers.cpp @@ -2,14 +2,15 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #include "spdlog/cfg/helpers.h" -#include "spdlog/details/registry.h" -#include "spdlog/spdlog.h" #include #include #include #include +#include "spdlog/details/registry.h" +#include "spdlog/spdlog.h" + namespace spdlog { namespace cfg { namespace helpers { diff --git a/src/details/file_helper.cpp b/src/details/file_helper.cpp index 1a6a119f..a28eccb4 100644 --- a/src/details/file_helper.cpp +++ b/src/details/file_helper.cpp @@ -1,15 +1,16 @@ // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) -#include "spdlog/common.h" #include "spdlog/details/file_helper.h" -#include "spdlog/details/os.h" #include #include #include #include +#include "spdlog/common.h" +#include "spdlog/details/os.h" + namespace spdlog { namespace details { diff --git a/src/details/log_msg.cpp b/src/details/log_msg.cpp index 6e212fff..ad800038 100644 --- a/src/details/log_msg.cpp +++ b/src/details/log_msg.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #include "spdlog/details/log_msg.h" + #include "spdlog/details/os.h" namespace spdlog { diff --git a/src/details/os.cpp b/src/details/os.cpp index 57f616cb..98dd59b2 100644 --- a/src/details/os.cpp +++ b/src/details/os.cpp @@ -1,9 +1,10 @@ // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) -#include "spdlog/common.h" #include "spdlog/details/os.h" +#include + #include #include #include @@ -12,9 +13,11 @@ #include #include #include -#include #include +#include "spdlog/common.h" + +// clang-format off #ifdef _WIN32 #include "spdlog/details/windows_include.h" #include // for FlushFileBuffers @@ -63,6 +66,7 @@ #define __has_feature(x) 0 // Compatibility with non-clang compilers. #endif +// clang-format on namespace spdlog { namespace details { namespace os { diff --git a/src/details/registry.cpp b/src/details/registry.cpp index 4a1708da..426364d5 100644 --- a/src/details/registry.cpp +++ b/src/details/registry.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #include "spdlog/details/registry.h" + #include "spdlog/common.h" #include "spdlog/details/periodic_worker.h" #include "spdlog/logger.h" diff --git a/src/details/thread_pool.cpp b/src/details/thread_pool.cpp index 94f9b676..2967e8c0 100644 --- a/src/details/thread_pool.cpp +++ b/src/details/thread_pool.cpp @@ -1,10 +1,12 @@ // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) -#include -#include "spdlog/common.h" #include "spdlog/details/thread_pool.h" +#include + +#include "spdlog/common.h" + namespace spdlog { namespace details { diff --git a/src/logger.cpp b/src/logger.cpp index 007ee9ea..3f540e25 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -2,12 +2,13 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #include "spdlog/logger.h" -#include "spdlog/pattern_formatter.h" -#include "spdlog/sinks/sink.h" #include #include +#include "spdlog/pattern_formatter.h" +#include "spdlog/sinks/sink.h" + namespace spdlog { // public methods diff --git a/src/pattern_formatter.cpp b/src/pattern_formatter.cpp index 2cd60250..40f0448a 100644 --- a/src/pattern_formatter.cpp +++ b/src/pattern_formatter.cpp @@ -1,13 +1,7 @@ // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) -#include "spdlog/details/fmt_helper.h" -#include "spdlog/details/log_msg.h" -#include "spdlog/details/os.h" -#include "spdlog/fmt/fmt.h" -#include "spdlog/formatter.h" #include "spdlog/pattern_formatter.h" -#include "spdlog/common.h" #include #include @@ -19,6 +13,13 @@ #include #include +#include "spdlog/common.h" +#include "spdlog/details/fmt_helper.h" +#include "spdlog/details/log_msg.h" +#include "spdlog/details/os.h" +#include "spdlog/fmt/fmt.h" +#include "spdlog/formatter.h" + namespace spdlog { namespace details { diff --git a/src/sinks/base_sink.cpp b/src/sinks/base_sink.cpp index 79aa029d..2275d5db 100644 --- a/src/sinks/base_sink.cpp +++ b/src/sinks/base_sink.cpp @@ -1,13 +1,14 @@ // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) -#include "spdlog/common.h" -#include "spdlog/pattern_formatter.h" #include "spdlog/sinks/base_sink.h" #include #include +#include "spdlog/common.h" +#include "spdlog/pattern_formatter.h" + template spdlog::sinks::base_sink::base_sink() : formatter_{std::make_unique()} {} diff --git a/src/sinks/rotating_file_sink.cpp b/src/sinks/rotating_file_sink.cpp index 8b28dbdc..3637ebe6 100644 --- a/src/sinks/rotating_file_sink.cpp +++ b/src/sinks/rotating_file_sink.cpp @@ -3,16 +3,16 @@ #include "spdlog/sinks/rotating_file_sink.h" -#include "spdlog/common.h" -#include "spdlog/details/file_helper.h" -#include "spdlog/details/os.h" -#include "spdlog/fmt/fmt.h" - #include #include #include #include +#include "spdlog/common.h" +#include "spdlog/details/file_helper.h" +#include "spdlog/details/os.h" +#include "spdlog/fmt/fmt.h" + namespace spdlog { namespace sinks { diff --git a/src/sinks/stdout_color_sinks.cpp b/src/sinks/stdout_color_sinks.cpp index 8fdc3442..3bd9fbc9 100644 --- a/src/sinks/stdout_color_sinks.cpp +++ b/src/sinks/stdout_color_sinks.cpp @@ -1,11 +1,12 @@ // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) +#include "spdlog/sinks/stdout_color_sinks.h" + #include "spdlog/async.h" #include "spdlog/common.h" #include "spdlog/details/synchronous_factory.h" #include "spdlog/logger.h" -#include "spdlog/sinks/stdout_color_sinks.h" namespace spdlog { diff --git a/src/sinks/stdout_sinks.cpp b/src/sinks/stdout_sinks.cpp index d191aa8b..d83a70ff 100644 --- a/src/sinks/stdout_sinks.cpp +++ b/src/sinks/stdout_sinks.cpp @@ -1,10 +1,13 @@ // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) -#include -#include "spdlog/pattern_formatter.h" #include "spdlog/sinks/stdout_sinks.h" +#include + +#include "spdlog/pattern_formatter.h" + +// clang-format off #ifdef _WIN32 // under windows using fwrite to non-binary stream results in \r\r\n (see issue #1675) // so instead we use ::FileWrite @@ -18,6 +21,7 @@ #include // _fileno(..) #endif // _WIN32 +// clang-format on namespace spdlog { namespace sinks { diff --git a/src/sinks/wincolor_sink.cpp b/src/sinks/wincolor_sink.cpp index a8e25d1e..9c42e814 100644 --- a/src/sinks/wincolor_sink.cpp +++ b/src/sinks/wincolor_sink.cpp @@ -2,13 +2,14 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #ifdef _WIN32 - #include "spdlog/common.h" - #include "spdlog/details/windows_include.h" - #include "spdlog/pattern_formatter.h" #include "spdlog/sinks/wincolor_sink.h" #include + #include "spdlog/common.h" + #include "spdlog/details/windows_include.h" + #include "spdlog/pattern_formatter.h" + namespace spdlog { namespace sinks { template diff --git a/src/spdlog.cpp b/src/spdlog.cpp index f2a5ba92..47551f01 100644 --- a/src/spdlog.cpp +++ b/src/spdlog.cpp @@ -1,9 +1,10 @@ // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. // Distributed under the MIT License (http://opensource.org/licenses/MIT) +#include "spdlog/spdlog.h" + #include "spdlog/common.h" #include "spdlog/pattern_formatter.h" -#include "spdlog/spdlog.h" namespace spdlog { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 659c67a9..7b8fc988 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -47,8 +47,7 @@ set(SPDLOG_UTESTS_SOURCES test_ringbuffer_sink.cpp test_source_location.cpp test_log_level.cpp - test_include_sinks.cpp -) + test_include_sinks.cpp) if(WIN32) list(APPEND SPDLOG_UTESTS_SOURCES test_eventlog.cpp) diff --git a/tests/includes.h b/tests/includes.h index 8514d642..9b6d8454 100644 --- a/tests/includes.h +++ b/tests/includes.h @@ -9,28 +9,30 @@ #pragma GCC diagnostic pop #endif -#include "utils.h" +#include + #include #include #include #include +#include #include #include #include #include -#include -#include + +#include "utils.h" #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG -#include "spdlog/spdlog.h" #include "spdlog/async.h" #include "spdlog/details/fmt_helper.h" +#include "spdlog/pattern_formatter.h" #include "spdlog/sinks/basic_file_sink.h" #include "spdlog/sinks/daily_file_sink.h" +#include "spdlog/sinks/msvc_sink.h" #include "spdlog/sinks/null_sink.h" #include "spdlog/sinks/ostream_sink.h" #include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/stdout_color_sinks.h" -#include "spdlog/sinks/msvc_sink.h" -#include "spdlog/pattern_formatter.h" +#include "spdlog/spdlog.h" diff --git a/tests/test_bin_to_hex.cpp b/tests/test_bin_to_hex.cpp index 45fc9fa9..7763a5c6 100644 --- a/tests/test_bin_to_hex.cpp +++ b/tests/test_bin_to_hex.cpp @@ -1,6 +1,6 @@ #include "includes.h" -#include "test_sink.h" #include "spdlog/fmt/bin_to_hex.h" +#include "test_sink.h" TEST_CASE("to_hex", "[to_hex]") { std::ostringstream oss; diff --git a/tests/test_cfg.cpp b/tests/test_cfg.cpp index fa66e959..9cfec7b5 100644 --- a/tests/test_cfg.cpp +++ b/tests/test_cfg.cpp @@ -1,9 +1,8 @@ #include "includes.h" -#include "test_sink.h" - -#include "spdlog/cfg/env.h" #include "spdlog/cfg/argv.h" +#include "spdlog/cfg/env.h" +#include "test_sink.h" using spdlog::cfg::load_argv_levels; using spdlog::cfg::load_env_levels; diff --git a/tests/test_custom_callbacks.cpp b/tests/test_custom_callbacks.cpp index 4b048572..33c7be42 100644 --- a/tests/test_custom_callbacks.cpp +++ b/tests/test_custom_callbacks.cpp @@ -3,10 +3,10 @@ * https://raw.githubusercontent.com/gabime/spdlog/master/LICENSE */ #include "includes.h" -#include "test_sink.h" -#include "spdlog/sinks/callback_sink.h" #include "spdlog/async.h" #include "spdlog/common.h" +#include "spdlog/sinks/callback_sink.h" +#include "test_sink.h" TEST_CASE("custom_callback_logger", "[custom_callback_logger]") { std::vector lines; diff --git a/tests/test_errors.cpp b/tests/test_errors.cpp index ccb447f8..05e9e9f7 100644 --- a/tests/test_errors.cpp +++ b/tests/test_errors.cpp @@ -2,10 +2,10 @@ * This content is released under the MIT License as specified in * https://raw.githubusercontent.com/gabime/spdlog/master/LICENSE */ -#include "includes.h" - #include +#include "includes.h" + #define SIMPLE_LOG "test_logs/simple_log.txt" #define SIMPLE_ASYNC_LOG "test_logs/simple_async_log.txt" diff --git a/tests/test_eventlog.cpp b/tests/test_eventlog.cpp index c8dcc8e4..78a8b195 100644 --- a/tests/test_eventlog.cpp +++ b/tests/test_eventlog.cpp @@ -1,8 +1,7 @@ #include "includes.h" -#include "test_sink.h" - #include "spdlog/sinks/win_eventlog_sink.h" +#include "test_sink.h" static const LPCSTR TEST_SOURCE = "spdlog_test"; @@ -70,5 +69,3 @@ TEST_CASE("eventlog", "[eventlog]") { test_single_print([&test_logger](std::string const &msg) { test_logger.critical(msg); }, "my critical message", EVENTLOG_ERROR_TYPE); } - - diff --git a/tests/test_include_sinks.cpp b/tests/test_include_sinks.cpp index ee95c57d..2845d759 100644 --- a/tests/test_include_sinks.cpp +++ b/tests/test_include_sinks.cpp @@ -20,6 +20,6 @@ #include "spdlog/sinks/udp_sink.h" #ifdef _WIN32 -#include "spdlog/sinks/wincolor_sink.h" -#include "spdlog/sinks/win_eventlog_sink.h" + #include "spdlog/sinks/win_eventlog_sink.h" + #include "spdlog/sinks/wincolor_sink.h" #endif diff --git a/tests/test_log_level.cpp b/tests/test_log_level.cpp index 94f0b1e5..60a30a5c 100644 --- a/tests/test_log_level.cpp +++ b/tests/test_log_level.cpp @@ -1,8 +1,9 @@ -#include "includes.h" -#include "test_sink.h" #include #include +#include "includes.h" +#include "test_sink.h" + TEST_CASE("test_default_level", "[log_level]") { auto test_sink = std::make_shared(); REQUIRE(test_sink->log_level() == spdlog::level::trace); diff --git a/tests/test_sink.h b/tests/test_sink.h index 529d86dd..827034d9 100644 --- a/tests/test_sink.h +++ b/tests/test_sink.h @@ -5,13 +5,14 @@ #pragma once -#include "spdlog/details/null_mutex.h" -#include "spdlog/sinks/base_sink.h" -#include "spdlog/fmt/fmt.h" #include #include #include +#include "spdlog/details/null_mutex.h" +#include "spdlog/fmt/fmt.h" +#include "spdlog/sinks/base_sink.h" + namespace spdlog { namespace sinks { diff --git a/tests/test_stdout_api.cpp b/tests/test_stdout_api.cpp index 4b5fc06d..07658989 100644 --- a/tests/test_stdout_api.cpp +++ b/tests/test_stdout_api.cpp @@ -3,8 +3,8 @@ * https://raw.githubusercontent.com/gabime/spdlog/master/LICENSE */ #include "includes.h" -#include "spdlog/sinks/stdout_sinks.h" #include "spdlog/sinks/stdout_color_sinks.h" +#include "spdlog/sinks/stdout_sinks.h" TEST_CASE("stdout_st", "[stdout]") { auto l = spdlog::stdout_logger_st("test"); l->set_pattern("%+"); diff --git a/tests/test_stopwatch.cpp b/tests/test_stopwatch.cpp index b2aa246b..5deb645d 100644 --- a/tests/test_stopwatch.cpp +++ b/tests/test_stopwatch.cpp @@ -1,6 +1,6 @@ #include "includes.h" -#include "test_sink.h" #include "spdlog/stopwatch.h" +#include "test_sink.h" TEST_CASE("stopwatch1", "[stopwatch]") { using std::chrono::milliseconds; diff --git a/tests/test_time_point.cpp b/tests/test_time_point.cpp index b7b1b232..c4399189 100644 --- a/tests/test_time_point.cpp +++ b/tests/test_time_point.cpp @@ -1,6 +1,6 @@ #include "includes.h" -#include "test_sink.h" #include "spdlog/async.h" +#include "test_sink.h" TEST_CASE("time_point1", "[time_point log_msg]") { std::shared_ptr test_sink(new spdlog::sinks::test_sink_st); diff --git a/tests/utils.cpp b/tests/utils.cpp index 1fa26175..6ca82df4 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -3,8 +3,8 @@ #ifdef _WIN32 #include #else - #include #include + #include #endif void prepare_logdir() {