Commit 65defd38 authored by gabime's avatar gabime

Replaced SPDLOG_FINAL macro with final

parent be7e7237
...@@ -40,7 +40,7 @@ namespace details { ...@@ -40,7 +40,7 @@ namespace details {
class thread_pool; class thread_pool;
} }
class async_logger SPDLOG_FINAL : public std::enable_shared_from_this<async_logger>, public logger class async_logger final : public std::enable_shared_from_this<async_logger>, public logger
{ {
friend class details::thread_pool; friend class details::thread_pool;
......
...@@ -32,13 +32,6 @@ ...@@ -32,13 +32,6 @@
#define SPDLOG_CONSTEXPR constexpr #define SPDLOG_CONSTEXPR constexpr
#endif #endif
// final keyword support. On by default. See tweakme.h
#if defined(SPDLOG_NO_FINAL)
#define SPDLOG_FINAL
#else
#define SPDLOG_FINAL final
#endif
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
#define SPDLOG_DEPRECATED __attribute__((deprecated)) #define SPDLOG_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
......
...@@ -116,7 +116,7 @@ class B_formatter : public flag_formatter ...@@ -116,7 +116,7 @@ class B_formatter : public flag_formatter
}; };
// Date and time representation (Thu Aug 23 15:35:46 2014) // Date and time representation (Thu Aug 23 15:35:46 2014)
class c_formatter SPDLOG_FINAL : public flag_formatter class c_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -142,7 +142,7 @@ class c_formatter SPDLOG_FINAL : public flag_formatter ...@@ -142,7 +142,7 @@ class c_formatter SPDLOG_FINAL : public flag_formatter
}; };
// year - 2 digit // year - 2 digit
class C_formatter SPDLOG_FINAL : public flag_formatter class C_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -151,7 +151,7 @@ class C_formatter SPDLOG_FINAL : public flag_formatter ...@@ -151,7 +151,7 @@ class C_formatter SPDLOG_FINAL : public flag_formatter
}; };
// Short MM/DD/YY date, equivalent to %m/%d/%y 08/23/01 // Short MM/DD/YY date, equivalent to %m/%d/%y 08/23/01
class D_formatter SPDLOG_FINAL : public flag_formatter class D_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -164,7 +164,7 @@ class D_formatter SPDLOG_FINAL : public flag_formatter ...@@ -164,7 +164,7 @@ class D_formatter SPDLOG_FINAL : public flag_formatter
}; };
// year - 4 digit // year - 4 digit
class Y_formatter SPDLOG_FINAL : public flag_formatter class Y_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -173,7 +173,7 @@ class Y_formatter SPDLOG_FINAL : public flag_formatter ...@@ -173,7 +173,7 @@ class Y_formatter SPDLOG_FINAL : public flag_formatter
}; };
// month 1-12 // month 1-12
class m_formatter SPDLOG_FINAL : public flag_formatter class m_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -182,7 +182,7 @@ class m_formatter SPDLOG_FINAL : public flag_formatter ...@@ -182,7 +182,7 @@ class m_formatter SPDLOG_FINAL : public flag_formatter
}; };
// day of month 1-31 // day of month 1-31
class d_formatter SPDLOG_FINAL : public flag_formatter class d_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -191,7 +191,7 @@ class d_formatter SPDLOG_FINAL : public flag_formatter ...@@ -191,7 +191,7 @@ class d_formatter SPDLOG_FINAL : public flag_formatter
}; };
// hours in 24 format 0-23 // hours in 24 format 0-23
class H_formatter SPDLOG_FINAL : public flag_formatter class H_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -200,7 +200,7 @@ class H_formatter SPDLOG_FINAL : public flag_formatter ...@@ -200,7 +200,7 @@ class H_formatter SPDLOG_FINAL : public flag_formatter
}; };
// hours in 12 format 1-12 // hours in 12 format 1-12
class I_formatter SPDLOG_FINAL : public flag_formatter class I_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -209,7 +209,7 @@ class I_formatter SPDLOG_FINAL : public flag_formatter ...@@ -209,7 +209,7 @@ class I_formatter SPDLOG_FINAL : public flag_formatter
}; };
// minutes 0-59 // minutes 0-59
class M_formatter SPDLOG_FINAL : public flag_formatter class M_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -218,7 +218,7 @@ class M_formatter SPDLOG_FINAL : public flag_formatter ...@@ -218,7 +218,7 @@ class M_formatter SPDLOG_FINAL : public flag_formatter
}; };
// seconds 0-59 // seconds 0-59
class S_formatter SPDLOG_FINAL : public flag_formatter class S_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -227,7 +227,7 @@ class S_formatter SPDLOG_FINAL : public flag_formatter ...@@ -227,7 +227,7 @@ class S_formatter SPDLOG_FINAL : public flag_formatter
}; };
// milliseconds // milliseconds
class e_formatter SPDLOG_FINAL : public flag_formatter class e_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -237,7 +237,7 @@ class e_formatter SPDLOG_FINAL : public flag_formatter ...@@ -237,7 +237,7 @@ class e_formatter SPDLOG_FINAL : public flag_formatter
}; };
// microseconds // microseconds
class f_formatter SPDLOG_FINAL : public flag_formatter class f_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -247,7 +247,7 @@ class f_formatter SPDLOG_FINAL : public flag_formatter ...@@ -247,7 +247,7 @@ class f_formatter SPDLOG_FINAL : public flag_formatter
}; };
// nanoseconds // nanoseconds
class F_formatter SPDLOG_FINAL : public flag_formatter class F_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -257,7 +257,7 @@ class F_formatter SPDLOG_FINAL : public flag_formatter ...@@ -257,7 +257,7 @@ class F_formatter SPDLOG_FINAL : public flag_formatter
}; };
// seconds since epoch // seconds since epoch
class E_formatter SPDLOG_FINAL : public flag_formatter class E_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -268,7 +268,7 @@ class E_formatter SPDLOG_FINAL : public flag_formatter ...@@ -268,7 +268,7 @@ class E_formatter SPDLOG_FINAL : public flag_formatter
}; };
// AM/PM // AM/PM
class p_formatter SPDLOG_FINAL : public flag_formatter class p_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -277,7 +277,7 @@ class p_formatter SPDLOG_FINAL : public flag_formatter ...@@ -277,7 +277,7 @@ class p_formatter SPDLOG_FINAL : public flag_formatter
}; };
// 12 hour clock 02:55:02 pm // 12 hour clock 02:55:02 pm
class r_formatter SPDLOG_FINAL : public flag_formatter class r_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -292,7 +292,7 @@ class r_formatter SPDLOG_FINAL : public flag_formatter ...@@ -292,7 +292,7 @@ class r_formatter SPDLOG_FINAL : public flag_formatter
}; };
// 24-hour HH:MM time, equivalent to %H:%M // 24-hour HH:MM time, equivalent to %H:%M
class R_formatter SPDLOG_FINAL : public flag_formatter class R_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -303,7 +303,7 @@ class R_formatter SPDLOG_FINAL : public flag_formatter ...@@ -303,7 +303,7 @@ class R_formatter SPDLOG_FINAL : public flag_formatter
}; };
// ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S // ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S
class T_formatter SPDLOG_FINAL : public flag_formatter class T_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -318,7 +318,7 @@ class T_formatter SPDLOG_FINAL : public flag_formatter ...@@ -318,7 +318,7 @@ class T_formatter SPDLOG_FINAL : public flag_formatter
}; };
// ISO 8601 offset from UTC in timezone (+-HH:MM) // ISO 8601 offset from UTC in timezone (+-HH:MM)
class z_formatter SPDLOG_FINAL : public flag_formatter class z_formatter final : public flag_formatter
{ {
public: public:
const std::chrono::seconds cache_refresh = std::chrono::seconds(5); const std::chrono::seconds cache_refresh = std::chrono::seconds(5);
...@@ -371,7 +371,7 @@ private: ...@@ -371,7 +371,7 @@ private:
}; };
// Thread id // Thread id
class t_formatter SPDLOG_FINAL : public flag_formatter class t_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -380,7 +380,7 @@ class t_formatter SPDLOG_FINAL : public flag_formatter ...@@ -380,7 +380,7 @@ class t_formatter SPDLOG_FINAL : public flag_formatter
}; };
// Current pid // Current pid
class pid_formatter SPDLOG_FINAL : public flag_formatter class pid_formatter final : public flag_formatter
{ {
void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -389,7 +389,7 @@ class pid_formatter SPDLOG_FINAL : public flag_formatter ...@@ -389,7 +389,7 @@ class pid_formatter SPDLOG_FINAL : public flag_formatter
}; };
// message counter formatter // message counter formatter
class i_formatter SPDLOG_FINAL : public flag_formatter class i_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -397,7 +397,7 @@ class i_formatter SPDLOG_FINAL : public flag_formatter ...@@ -397,7 +397,7 @@ class i_formatter SPDLOG_FINAL : public flag_formatter
} }
}; };
class v_formatter SPDLOG_FINAL : public flag_formatter class v_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -405,7 +405,7 @@ class v_formatter SPDLOG_FINAL : public flag_formatter ...@@ -405,7 +405,7 @@ class v_formatter SPDLOG_FINAL : public flag_formatter
} }
}; };
class ch_formatter SPDLOG_FINAL : public flag_formatter class ch_formatter final : public flag_formatter
{ {
public: public:
explicit ch_formatter(char ch) explicit ch_formatter(char ch)
...@@ -422,7 +422,7 @@ private: ...@@ -422,7 +422,7 @@ private:
}; };
// aggregate user chars to display as is // aggregate user chars to display as is
class aggregate_formatter SPDLOG_FINAL : public flag_formatter class aggregate_formatter final : public flag_formatter
{ {
public: public:
aggregate_formatter() = default; aggregate_formatter() = default;
...@@ -441,14 +441,14 @@ private: ...@@ -441,14 +441,14 @@ private:
}; };
// mark the color range. expect it to be in the form of "%^colored text%$" // mark the color range. expect it to be in the form of "%^colored text%$"
class color_start_formatter SPDLOG_FINAL : public flag_formatter class color_start_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
msg.color_range_start = dest.size(); msg.color_range_start = dest.size();
} }
}; };
class color_stop_formatter SPDLOG_FINAL : public flag_formatter class color_stop_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
{ {
...@@ -458,7 +458,7 @@ class color_stop_formatter SPDLOG_FINAL : public flag_formatter ...@@ -458,7 +458,7 @@ class color_stop_formatter SPDLOG_FINAL : public flag_formatter
// Full info formatter // Full info formatter
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v // pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v
class full_formatter SPDLOG_FINAL : public flag_formatter class full_formatter final : public flag_formatter
{ {
void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override void format(const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override
{ {
...@@ -528,7 +528,7 @@ private: ...@@ -528,7 +528,7 @@ private:
} // namespace details } // namespace details
class pattern_formatter SPDLOG_FINAL : public formatter class pattern_formatter final : public formatter
{ {
public: public:
explicit pattern_formatter( explicit pattern_formatter(
......
...@@ -25,7 +25,7 @@ namespace sinks { ...@@ -25,7 +25,7 @@ namespace sinks {
* If no color terminal detected, omit the escape codes. * If no color terminal detected, omit the escape codes.
*/ */
template<typename TargetStream, class ConsoleMutex> template<typename TargetStream, class ConsoleMutex>
class ansicolor_sink SPDLOG_FINAL : public sink class ansicolor_sink final : public sink
{ {
public: public:
using mutex_t = typename ConsoleMutex::mutex_t; using mutex_t = typename ConsoleMutex::mutex_t;
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
fflush(target_file_); fflush(target_file_);
} }
void set_pattern(const std::string &pattern) SPDLOG_FINAL void set_pattern(const std::string &pattern) final
{ {
std::lock_guard<mutex_t> lock(mutex_); std::lock_guard<mutex_t> lock(mutex_);
formatter_ = std::unique_ptr<spdlog::formatter>(new pattern_formatter(pattern)); formatter_ = std::unique_ptr<spdlog::formatter>(new pattern_formatter(pattern));
......
...@@ -30,25 +30,25 @@ public: ...@@ -30,25 +30,25 @@ public:
base_sink(const base_sink &) = delete; base_sink(const base_sink &) = delete;
base_sink &operator=(const base_sink &) = delete; base_sink &operator=(const base_sink &) = delete;
void log(const details::log_msg &msg) SPDLOG_FINAL void log(const details::log_msg &msg) final
{ {
std::lock_guard<Mutex> lock(mutex_); std::lock_guard<Mutex> lock(mutex_);
sink_it_(msg); sink_it_(msg);
} }
void flush() SPDLOG_FINAL override void flush() final override
{ {
std::lock_guard<Mutex> lock(mutex_); std::lock_guard<Mutex> lock(mutex_);
flush_(); flush_();
} }
void set_pattern(const std::string &pattern) SPDLOG_FINAL override void set_pattern(const std::string &pattern) final override
{ {
std::lock_guard<Mutex> lock(mutex_); std::lock_guard<Mutex> lock(mutex_);
formatter_ = std::unique_ptr<spdlog::formatter>(new pattern_formatter(pattern)); formatter_ = std::unique_ptr<spdlog::formatter>(new pattern_formatter(pattern));
} }
void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) SPDLOG_FINAL override void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) final override
{ {
std::lock_guard<Mutex> lock(mutex_); std::lock_guard<Mutex> lock(mutex_);
formatter_ = std::move(sink_formatter); formatter_ = std::move(sink_formatter);
......
...@@ -18,7 +18,7 @@ namespace sinks { ...@@ -18,7 +18,7 @@ namespace sinks {
* Trivial file sink with single file as target * Trivial file sink with single file as target
*/ */
template<typename Mutex> template<typename Mutex>
class basic_file_sink SPDLOG_FINAL : public base_sink<Mutex> class basic_file_sink final : public base_sink<Mutex>
{ {
public: public:
explicit basic_file_sink(const filename_t &filename, bool truncate = false) explicit basic_file_sink(const filename_t &filename, bool truncate = false)
......
...@@ -40,7 +40,7 @@ struct daily_filename_calculator ...@@ -40,7 +40,7 @@ struct daily_filename_calculator
* Rotating file sink based on date. rotates at midnight * Rotating file sink based on date. rotates at midnight
*/ */
template<typename Mutex, typename FileNameCalc = daily_filename_calculator> template<typename Mutex, typename FileNameCalc = daily_filename_calculator>
class daily_file_sink SPDLOG_FINAL : public base_sink<Mutex> class daily_file_sink final : public base_sink<Mutex>
{ {
public: public:
// create daily file sink which rotates on given time // create daily file sink which rotates on given time
......
...@@ -24,7 +24,7 @@ namespace sinks { ...@@ -24,7 +24,7 @@ namespace sinks {
// Rotating file sink based on size // Rotating file sink based on size
// //
template<typename Mutex> template<typename Mutex>
class rotating_file_sink SPDLOG_FINAL : public base_sink<Mutex> class rotating_file_sink final : public base_sink<Mutex>
{ {
public: public:
rotating_file_sink(filename_t base_filename, std::size_t max_size, std::size_t max_files) rotating_file_sink(filename_t base_filename, std::size_t max_size, std::size_t max_files)
......
...@@ -108,15 +108,6 @@ ...@@ -108,15 +108,6 @@
// #define SPDLOG_PREVENT_CHILD_FD // #define SPDLOG_PREVENT_CHILD_FD
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if your compiler doesn't support the "final" keyword.
// The final keyword allows more optimizations in release
// mode with recent compilers. See GCC's documentation for -Wsuggest-final-types
// for instance.
//
// #define SPDLOG_NO_FINAL
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable message counting feature. // Uncomment to enable message counting feature.
// Use the %i in the logger pattern to display log message sequence id. // Use the %i in the logger pattern to display log message sequence id.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment