Removed SPDLOG_NO_DATETIME option
This commit is contained in:
		@@ -76,7 +76,6 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
 | 
				
			|||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" OFF)
 | 
					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_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_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)
 | 
					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)
 | 
					    target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_PREVENT_CHILD_FD)
 | 
				
			||||||
endif()
 | 
					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)
 | 
					if(SPDLOG_NO_THREAD_ID)
 | 
				
			||||||
    target_compile_definitions(spdlog PRIVATE SPDLOG_NO_THREAD_ID)
 | 
					    target_compile_definitions(spdlog PRIVATE SPDLOG_NO_THREAD_ID)
 | 
				
			||||||
    target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_THREAD_ID)
 | 
					    target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_THREAD_ID)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)
 | 
					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)
 | 
					    : logger_name(logger_name)
 | 
				
			||||||
    , level(lvl)
 | 
					    , level(lvl)
 | 
				
			||||||
#ifndef SPDLOG_NO_DATETIME
 | 
					 | 
				
			||||||
    , time(os::now())
 | 
					    , time(os::now())
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef SPDLOG_NO_THREAD_ID
 | 
					#ifndef SPDLOG_NO_THREAD_ID
 | 
				
			||||||
    , thread_id(os::thread_id())
 | 
					    , thread_id(os::thread_id())
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -904,8 +904,6 @@ public:
 | 
				
			|||||||
        using std::chrono::milliseconds;
 | 
					        using std::chrono::milliseconds;
 | 
				
			||||||
        using std::chrono::seconds;
 | 
					        using std::chrono::seconds;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef SPDLOG_NO_DATETIME
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // cache the date/time part for the next second.
 | 
					        // cache the date/time part for the next second.
 | 
				
			||||||
        auto duration = msg.time.time_since_epoch();
 | 
					        auto duration = msg.time.time_since_epoch();
 | 
				
			||||||
        auto secs = duration_cast<seconds>(duration);
 | 
					        auto secs = duration_cast<seconds>(duration);
 | 
				
			||||||
@@ -941,10 +939,6 @@ public:
 | 
				
			|||||||
        dest.push_back(']');
 | 
					        dest.push_back(']');
 | 
				
			||||||
        dest.push_back(' ');
 | 
					        dest.push_back(' ');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else // no datetime needed
 | 
					 | 
				
			||||||
        (void)tm_time;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef SPDLOG_NO_NAME
 | 
					#ifndef SPDLOG_NO_NAME
 | 
				
			||||||
        if (msg.logger_name.size() > 0)
 | 
					        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)
 | 
					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());
 | 
					    auto secs = std::chrono::duration_cast<std::chrono::seconds>(msg.time.time_since_epoch());
 | 
				
			||||||
    if (secs != last_log_secs_)
 | 
					    if (secs != last_log_secs_)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        cached_tm_ = get_time_(msg);
 | 
					        cached_tm_ = get_time_(msg);
 | 
				
			||||||
        last_log_secs_ = secs;
 | 
					        last_log_secs_ = secs;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					
 | 
				
			||||||
    for (auto &f : formatters_)
 | 
					    for (auto &f : formatters_)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        f->format(msg, cached_tm_, dest);
 | 
					        f->format(msg, cached_tm_, dest);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,12 +78,7 @@ public:
 | 
				
			|||||||
protected:
 | 
					protected:
 | 
				
			||||||
    void sink_it_(const details::log_msg &msg) override
 | 
					    void sink_it_(const details::log_msg &msg) override
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
#ifdef SPDLOG_NO_DATETIME
 | 
					 | 
				
			||||||
        auto time = log_clock::now();
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
        auto time = msg.time;
 | 
					        auto time = msg.time;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        bool should_rotate = time >= rotation_tp_;
 | 
					        bool should_rotate = time >= rotation_tp_;
 | 
				
			||||||
        if (should_rotate)
 | 
					        if (should_rotate)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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] Skipped 3 duplicate messages..
 | 
				
			||||||
//       [2019-06-25 17:50:56.512] [logger] [info] Different Hello
 | 
					//       [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 spdlog {
 | 
				
			||||||
namespace sinks {
 | 
					namespace sinks {
 | 
				
			||||||
template<typename Mutex>
 | 
					template<typename Mutex>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,19 +19,6 @@
 | 
				
			|||||||
// #define SPDLOG_CLOCK_COARSE
 | 
					// #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).
 | 
					// 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.
 | 
					// This will prevent spdlog from querying the thread id on each log call.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,7 @@ set(SPDLOG_UTESTS_SOURCES
 | 
				
			|||||||
    main.cpp
 | 
					    main.cpp
 | 
				
			||||||
    test_mpmc_q.cpp
 | 
					    test_mpmc_q.cpp
 | 
				
			||||||
    test_sink.h
 | 
					    test_sink.h
 | 
				
			||||||
 | 
						test_dup_filter.cpp
 | 
				
			||||||
    test_fmt_helper.cpp
 | 
					    test_fmt_helper.cpp
 | 
				
			||||||
  	test_stdout_api.cpp
 | 
					  	test_stdout_api.cpp
 | 
				
			||||||
	test_backtrace.cpp
 | 
						test_backtrace.cpp
 | 
				
			||||||
@@ -35,12 +36,6 @@ if(systemd_FOUND)
 | 
				
			|||||||
	list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp)
 | 
						list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(NOT SPDLOG_NO_DATETIME)
 | 
					 | 
				
			||||||
	list(APPEND SPDLOG_UTESTS_SOURCES test_dup_filter.cpp)
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
enable_testing()
 | 
					enable_testing()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user