mirror of
https://github.com/gabime/spdlog.git
synced 2026-01-02 09:57:55 +08:00
clang-format
This commit is contained in:
@@ -20,8 +20,8 @@ include(GNUInstallDirs)
|
|||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
# Set CMAKE_BUILD_TYPE only if this project is top-level
|
# Set CMAKE_BUILD_TYPE only if this project is top-level
|
||||||
if((DEFINED PROJECT_IS_TOP_LEVEL AND PROJECT_IS_TOP_LEVEL)
|
if((DEFINED PROJECT_IS_TOP_LEVEL AND PROJECT_IS_TOP_LEVEL) OR (NOT DEFINED PROJECT_IS_TOP_LEVEL
|
||||||
OR (NOT DEFINED PROJECT_IS_TOP_LEVEL AND CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR))
|
AND CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR))
|
||||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -99,7 +99,6 @@ option(SPDLOG_FMT_EXTERNAL_HO "Use external fmt header-only library instead of b
|
|||||||
option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
|
option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
|
||||||
option(SPDLOG_NO_TZ_OFFSET "Omit %z timezone offset (use on platforms without tm_gmtoff)" OFF)
|
option(SPDLOG_NO_TZ_OFFSET "Omit %z timezone offset (use on platforms without tm_gmtoff)" OFF)
|
||||||
|
|
||||||
|
|
||||||
if(SPDLOG_FMT_EXTERNAL AND SPDLOG_FMT_EXTERNAL_HO)
|
if(SPDLOG_FMT_EXTERNAL AND SPDLOG_FMT_EXTERNAL_HO)
|
||||||
message(FATAL_ERROR "SPDLOG_FMT_EXTERNAL and SPDLOG_FMT_EXTERNAL_HO are mutually exclusive")
|
message(FATAL_ERROR "SPDLOG_FMT_EXTERNAL and SPDLOG_FMT_EXTERNAL_HO are mutually exclusive")
|
||||||
endif()
|
endif()
|
||||||
@@ -289,8 +288,7 @@ foreach(
|
|||||||
SPDLOG_NO_ATOMIC_LEVELS
|
SPDLOG_NO_ATOMIC_LEVELS
|
||||||
SPDLOG_DISABLE_DEFAULT_LOGGER
|
SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||||
SPDLOG_USE_STD_FORMAT
|
SPDLOG_USE_STD_FORMAT
|
||||||
SPDLOG_NO_TZ_OFFSET
|
SPDLOG_NO_TZ_OFFSET)
|
||||||
)
|
|
||||||
if(${SPDLOG_OPTION})
|
if(${SPDLOG_OPTION})
|
||||||
target_compile_definitions(spdlog PUBLIC ${SPDLOG_OPTION})
|
target_compile_definitions(spdlog PUBLIC ${SPDLOG_OPTION})
|
||||||
target_compile_definitions(spdlog_header_only INTERFACE ${SPDLOG_OPTION})
|
target_compile_definitions(spdlog_header_only INTERFACE ${SPDLOG_OPTION})
|
||||||
|
|||||||
@@ -246,14 +246,14 @@ SPDLOG_INLINE size_t filesize(FILE *f) {
|
|||||||
// Return utc offset in minutes or throw spdlog_ex on failure
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
||||||
#if !defined(SPDLOG_NO_TZ_OFFSET)
|
#if !defined(SPDLOG_NO_TZ_OFFSET)
|
||||||
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
||||||
TIME_ZONE_INFORMATION tzinfo;
|
TIME_ZONE_INFORMATION tzinfo;
|
||||||
auto rv = ::GetTimeZoneInformation(&tzinfo);
|
auto rv = ::GetTimeZoneInformation(&tzinfo);
|
||||||
#else
|
#else
|
||||||
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
||||||
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
||||||
#endif
|
#endif
|
||||||
if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno);
|
if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno);
|
||||||
|
|
||||||
int offset = -tzinfo.Bias;
|
int offset = -tzinfo.Bias;
|
||||||
@@ -263,12 +263,12 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) {
|
|||||||
offset -= tzinfo.StandardBias;
|
offset -= tzinfo.StandardBias;
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
#else
|
#else
|
||||||
auto offset_seconds = tm.tm_gmtoff;
|
auto offset_seconds = tm.tm_gmtoff;
|
||||||
return static_cast<int>(offset_seconds / 60);
|
return static_cast<int>(offset_seconds / 60);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // SPDLOG_NO_TZ_OFFSET
|
#endif // SPDLOG_NO_TZ_OFFSET
|
||||||
|
|
||||||
// Return current thread id as size_t
|
// Return current thread id as size_t
|
||||||
// It exists because the std::this_thread::get_id() is much slower(especially
|
// It exists because the std::this_thread::get_id() is much slower(especially
|
||||||
|
|||||||
@@ -525,10 +525,10 @@ public:
|
|||||||
const size_t field_size = 6;
|
const size_t field_size = 6;
|
||||||
ScopedPadder p(field_size, padinfo_, dest);
|
ScopedPadder p(field_size, padinfo_, dest);
|
||||||
|
|
||||||
#ifdef SPDLOG_NO_TZ_OFFSET
|
#ifdef SPDLOG_NO_TZ_OFFSET
|
||||||
const char *str = "+??:??";
|
const char *str = "+??:??";
|
||||||
dest.append(str, str + 6);
|
dest.append(str, str + 6);
|
||||||
#else
|
#else
|
||||||
auto total_minutes = get_cached_offset(msg, tm_time);
|
auto total_minutes = get_cached_offset(msg, tm_time);
|
||||||
bool is_negative = total_minutes < 0;
|
bool is_negative = total_minutes < 0;
|
||||||
if (is_negative) {
|
if (is_negative) {
|
||||||
@@ -541,7 +541,7 @@ public:
|
|||||||
fmt_helper::pad2(total_minutes / 60, dest); // hours
|
fmt_helper::pad2(total_minutes / 60, dest); // hours
|
||||||
dest.push_back(':');
|
dest.push_back(':');
|
||||||
fmt_helper::pad2(total_minutes % 60, dest); // minutes
|
fmt_helper::pad2(total_minutes % 60, dest); // minutes
|
||||||
#endif // SPDLOG_NO_TZ_OFFSET
|
#endif // SPDLOG_NO_TZ_OFFSET
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1161,8 +1161,8 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i
|
|||||||
need_localtime_ = true;
|
need_localtime_ = true;
|
||||||
break;
|
break;
|
||||||
case ('z'): // timezone
|
case ('z'): // timezone
|
||||||
formatters_.push_back(details::make_unique<details::z_formatter<Padder>>(padding));
|
formatters_.push_back(details::make_unique<details::z_formatter<Padder>>(padding));
|
||||||
need_localtime_ = true;
|
need_localtime_ = true;
|
||||||
break;
|
break;
|
||||||
case ('P'): // pid
|
case ('P'): // pid
|
||||||
formatters_.push_back(details::make_unique<details::pid_formatter<Padder>>(padding));
|
formatters_.push_back(details::make_unique<details::pid_formatter<Padder>>(padding));
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ TEST_CASE("GMT offset ", "[pattern_formatter]") {
|
|||||||
#else
|
#else
|
||||||
const std::string expected_result = "+??:??\n";
|
const std::string expected_result = "+??:??\n";
|
||||||
#endif
|
#endif
|
||||||
REQUIRE(log_to_str_with_time(yesterday, "Some message", "%z", spdlog::pattern_time_type::utc, "\n") == expected_result);
|
REQUIRE(log_to_str_with_time(yesterday, "Some message", "%z", spdlog::pattern_time_type::utc,
|
||||||
|
"\n") == expected_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("color range test1", "[pattern_formatter]") {
|
TEST_CASE("color range test1", "[pattern_formatter]") {
|
||||||
|
|||||||
Reference in New Issue
Block a user