Removed SPDLOG_NO_DATETIME option

This commit is contained in:
gabime 2019-11-04 17:43:30 +02:00
parent 18edb8bd63
commit 10116b7717
7 changed files with 2 additions and 46 deletions

View File

@ -76,7 +76,6 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
endif()
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" OFF)
option(SPDLOG_NO_DATETIME, "Prevent spdlog from querying the clock on each log call if no datetime is needed" OFF)
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" OFF)
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" OFF)
option(SPDLOG_NO_ATOMIC_LEVELS "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" OFF)
@ -180,12 +179,6 @@ if(SPDLOG_PREVENT_CHILD_FD)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_PREVENT_CHILD_FD)
endif()
if(SPDLOG_NO_DATETIME)
target_compile_definitions(spdlog PUBLIC SPDLOG_NO_DATETIME)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_DATETIME)
endif()
if(SPDLOG_NO_THREAD_ID)
target_compile_definitions(spdlog PRIVATE SPDLOG_NO_THREAD_ID)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_THREAD_ID)

View File

@ -15,10 +15,7 @@ namespace details {
SPDLOG_INLINE log_msg::log_msg(spdlog::source_loc loc, string_view_t logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg)
: logger_name(logger_name)
, level(lvl)
#ifndef SPDLOG_NO_DATETIME
, time(os::now())
#endif
#ifndef SPDLOG_NO_THREAD_ID
, thread_id(os::thread_id())
#endif

View File

@ -904,8 +904,6 @@ public:
using std::chrono::milliseconds;
using std::chrono::seconds;
#ifndef SPDLOG_NO_DATETIME
// cache the date/time part for the next second.
auto duration = msg.time.time_since_epoch();
auto secs = duration_cast<seconds>(duration);
@ -941,10 +939,6 @@ public:
dest.push_back(']');
dest.push_back(' ');
#else // no datetime needed
(void)tm_time;
#endif
#ifndef SPDLOG_NO_NAME
if (msg.logger_name.size() > 0)
{
@ -1014,14 +1008,13 @@ SPDLOG_INLINE std::unique_ptr<formatter> pattern_formatter::clone() const
SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, memory_buf_t &dest)
{
#ifndef SPDLOG_NO_DATETIME
auto secs = std::chrono::duration_cast<std::chrono::seconds>(msg.time.time_since_epoch());
if (secs != last_log_secs_)
{
cached_tm_ = get_time_(msg);
last_log_secs_ = secs;
}
#endif
for (auto &f : formatters_)
{
f->format(msg, cached_tm_, dest);

View File

@ -78,12 +78,7 @@ public:
protected:
void sink_it_(const details::log_msg &msg) override
{
#ifdef SPDLOG_NO_DATETIME
auto time = log_clock::now();
#else
auto time = msg.time;
#endif
bool should_rotate = time >= rotation_tp_;
if (should_rotate)
{

View File

@ -33,10 +33,6 @@
// [2019-06-25 17:50:56.512] [logger] [info] Skipped 3 duplicate messages..
// [2019-06-25 17:50:56.512] [logger] [info] Different Hello
#ifdef SPDLOG_NO_DATETIME
#error "spdlog::sinks::dup_filter_sink: cannot work when SPDLOG_NO_DATETIME is defined"
#endif
namespace spdlog {
namespace sinks {
template<typename Mutex>

View File

@ -19,19 +19,6 @@
// #define SPDLOG_CLOCK_COARSE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if date/time logging is not needed and never appear in the log
// pattern.
// This will prevent spdlog from querying the clock on each log call.
//
// WARNING: If the log pattern contains any date/time while this flag is on, the
// result is undefined.
// You must set new pattern(spdlog::set_pattern(..") without any
// date/time in it
//
// #define SPDLOG_NO_DATETIME
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// 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.

View File

@ -22,6 +22,7 @@ set(SPDLOG_UTESTS_SOURCES
main.cpp
test_mpmc_q.cpp
test_sink.h
test_dup_filter.cpp
test_fmt_helper.cpp
test_stdout_api.cpp
test_backtrace.cpp
@ -35,12 +36,6 @@ if(systemd_FOUND)
list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp)
endif()
if(NOT SPDLOG_NO_DATETIME)
list(APPEND SPDLOG_UTESTS_SOURCES test_dup_filter.cpp)
endif()
enable_testing()