From 7ce276b9d438b38c220bc2ccd0b34a8dc9d41420 Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Tue, 20 Feb 2024 23:06:50 +0100 Subject: [PATCH] feat: remove deprecations --- CMakeLists.txt | 4 +- src/glog/logging.h | 73 ++------------------------ src/logging.cc | 125 +-------------------------------------------- 3 files changed, 7 insertions(+), 195 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b787631ce..847530698 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.22) project (glog - VERSION 0.7.0 + VERSION 0.8.0 DESCRIPTION "C++ implementation of the Google logging module" HOMEPAGE_URL https://github.com/google/glog LANGUAGES CXX @@ -466,7 +466,7 @@ if (ANDROID) endif (ANDROID) set_target_properties (glog PROPERTIES VERSION ${glog_VERSION}) -set_target_properties (glog PROPERTIES SOVERSION 2) +set_target_properties (glog PROPERTIES SOVERSION 3) if (CYGWIN OR WIN32) target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES) diff --git a/src/glog/logging.h b/src/glog/logging.h index 88d793f18..6e36eaadf 100644 --- a/src/glog/logging.h +++ b/src/glog/logging.h @@ -83,10 +83,6 @@ struct GLOG_EXPORT LogMessageTime { LogMessageTime(); explicit LogMessageTime(std::chrono::system_clock::time_point now); - [[deprecated("Use LogMessageTime::when() instead.")]] std::time_t timestamp() - const noexcept { - return std::chrono::system_clock::to_time_t(when()); - } const std::chrono::system_clock::time_point& when() const noexcept { return timestamp_; } @@ -100,10 +96,6 @@ struct GLOG_EXPORT LogMessageTime { int dayOfWeek() const noexcept { return tm_.tm_wday; } int dayInYear() const noexcept { return tm_.tm_yday; } int dst() const noexcept { return tm_.tm_isdst; } - [[deprecated("Use LogMessageTime::gmtoffset() instead.")]] long gmtoff() - const noexcept { - return gmtoffset_.count(); - } std::chrono::seconds gmtoffset() const noexcept { return gmtoffset_; } const std::tm& tm() const noexcept { return tm_; } @@ -115,24 +107,6 @@ struct GLOG_EXPORT LogMessageTime { std::chrono::seconds gmtoffset_; }; -struct [[deprecated("Use LogMessage instead.")]] LogMessageInfo { - explicit LogMessageInfo(const char* const severity_, - const char* const filename_, const int& line_number_, - std::thread::id thread_id_, - const LogMessageTime& time_) - : severity(severity_), - filename(filename_), - line_number(line_number_), - thread_id(thread_id_), - time(time_) {} - - const char* const severity; - const char* const filename; - const int& line_number; - std::thread::id thread_id; - const LogMessageTime& time; -}; - } // namespace google // The global value of GOOGLE_STRIP_LOG. All the messages logged to @@ -482,27 +456,6 @@ namespace google { // specified by argv0 in log outputs. GLOG_EXPORT void InitGoogleLogging(const char* argv0); -class LogMessage; - -#if defined(__GNUG__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4996) -#endif // __GNUG__ -using CustomPrefixCallback - [[deprecated("Use PrefixFormatterCallback instead.")]] = - void (*)(std::ostream&, const LogMessageInfo&, void*); -#if defined(__GNUG__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER) -# pragma warning(pop) -#endif // __GNUG__ -[[deprecated("Use InstallPrefixFormatter instead.")]] GLOG_EXPORT void -InitGoogleLogging(const char* argv0, CustomPrefixCallback prefix_callback, - void* prefix_callback_data = nullptr); - // Check if google's logging library has been initialized. GLOG_EXPORT bool IsGoogleLoggingInitialized(); @@ -515,6 +468,8 @@ typedef void (*logging_fail_func_t)() __attribute__((noreturn)); typedef void (*logging_fail_func_t)(); #endif +class LogMessage; + using PrefixFormatterCallback = void (*)(std::ostream&, const LogMessage&, void*); @@ -526,10 +481,6 @@ GLOG_EXPORT void InstallPrefixFormatter(PrefixFormatterCallback callback, GLOG_EXPORT logging_fail_func_t InstallFailureFunction(logging_fail_func_t fail_func); -[[deprecated( - "Use the type-safe std::chrono::minutes EnableLogCleaner overload " - "instead.")]] GLOG_EXPORT void -EnableLogCleaner(unsigned int overdue_days); // Enable/Disable old log cleaner. GLOG_EXPORT void EnableLogCleaner(const std::chrono::minutes& overdue); GLOG_EXPORT void DisableLogCleaner(); @@ -1361,11 +1312,6 @@ class GLOG_EXPORT LogMessage { // Must be called without the log_mutex held. (L < log_mutex) static int64 num_messages(int severity); - [[deprecated("Use LogMessage::time() instead.")]] const LogMessageTime& - getLogMessageTime() const { - return time(); - } - LogSeverity severity() const noexcept; int line() const noexcept; const std::thread::id& thread_id() const noexcept; @@ -1520,12 +1466,7 @@ class GLOG_EXPORT LogSink { virtual void send(LogSeverity severity, const char* full_filename, const char* base_filename, int line, const LogMessageTime& time, const char* message, - size_t message_len); - // Provide an overload for compatibility purposes - GLOG_DEPRECATED - virtual void send(LogSeverity severity, const char* full_filename, - const char* base_filename, int line, const std::tm* t, - const char* message, size_t message_len); + size_t message_len) = 0; // Redefine this to implement waiting for // the sink's logging logic to complete. @@ -1637,15 +1578,9 @@ class GLOG_EXPORT Logger { // appropriate by the higher level logging facility. For example, // textual log messages already contain timestamps, and the // file:linenumber header. - [[deprecated( - "Logger::Write accepting a std::time_t timestamp is provided for " - "compatibility purposes only. New code should implement the " - "std::chrono::system_clock::time_point overload.")]] virtual void - Write(bool force_flush, time_t timestamp, const char* message, - size_t message_len); virtual void Write(bool force_flush, const std::chrono::system_clock::time_point& timestamp, - const char* message, size_t message_len); + const char* message, size_t message_len) = 0; // Flush any buffered messages virtual void Flush() = 0; diff --git a/src/logging.cc b/src/logging.cc index fc6399529..08b2ab387 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -342,28 +342,6 @@ static bool SendEmailInternal(const char* dest, const char* subject, base::Logger::~Logger() = default; -void base::Logger::Write(bool /*force_flush*/, time_t /*timestamp*/, - const char* /*message*/, size_t /*message_len*/) {} - -void base::Logger::Write(bool force_flush, - const std::chrono::system_clock::time_point& timestamp, - const char* message, size_t message_len) { -#if defined(__GNUG__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4996) -#endif // __GNUG__ - return Write(force_flush, std::chrono::system_clock::to_time_t(timestamp), - message, message_len); -#if defined(__GNUG__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER) -# pragma warning(pop) -#endif // __GNUG__ -} - namespace { constexpr std::intmax_t kSecondsInDay = 60 * 60 * 24; @@ -372,44 +350,11 @@ constexpr std::intmax_t kSecondsInWeek = kSecondsInDay * 7; // Optional user-configured callback to print custom prefixes. class PrefixFormatter { public: -#if defined(__GNUG__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4996) -#endif // __GNUG__ - PrefixFormatter(CustomPrefixCallback callback, void* data) noexcept - : version{V1}, callback_v1{callback}, data{data} {} -#if defined(__GNUG__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER) -# pragma warning(pop) -#endif // __GNUG__ PrefixFormatter(PrefixFormatterCallback callback, void* data) noexcept : version{V2}, callback_v2{callback}, data{data} {} void operator()(std::ostream& s, const LogMessage& message) const { switch (version) { - case V1: -#if defined(__GNUG__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4996) -#endif // __GNUG__ - callback_v1(s, - LogMessageInfo(LogSeverityNames[message.severity()], - message.basename(), message.line(), - message.thread_id(), message.time()), - data); -#if defined(__GNUG__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER) -# pragma warning(pop) -#endif // __GNUG__ - break; case V2: callback_v2(s, message, data); break; @@ -420,21 +365,8 @@ class PrefixFormatter { PrefixFormatter& operator=(const PrefixFormatter& other) = delete; private: - enum Version { V1, V2 } version; + enum Version { V2 } version; union { -#if defined(__GNUG__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4996) -#endif // __GNUG__ - CustomPrefixCallback callback_v1; -#if defined(__GNUG__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER) -# pragma warning(pop) -#endif // __GNUG__ PrefixFormatterCallback callback_v2; }; // User-provided data to pass to the callback: @@ -2081,38 +2013,6 @@ void SetLogSymlink(LogSeverity severity, const char* symlink_basename) { LogSink::~LogSink() = default; -void LogSink::send(LogSeverity severity, const char* full_filename, - const char* base_filename, int line, - const LogMessageTime& time, const char* message, - size_t message_len) { -#if defined(__GNUG__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4996) -#endif // __GNUG__ - send(severity, full_filename, base_filename, line, &time.tm(), message, - message_len); -#if defined(__GNUG__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER) -# pragma warning(pop) -#endif // __GNUG__ -} - -void LogSink::send(LogSeverity severity, const char* full_filename, - const char* base_filename, int line, const std::tm* t, - const char* message, size_t message_len) { - (void)severity; - (void)full_filename; - (void)base_filename; - (void)line; - (void)t; - (void)message; - (void)message_len; -} - void LogSink::WaitTillSent() { // noop default } @@ -2702,29 +2602,6 @@ void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& /*v*/) { void InitGoogleLogging(const char* argv0) { InitGoogleLoggingUtilities(argv0); } -#if defined(__GNUG__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4996) -#endif // __GNUG__ -void InitGoogleLogging(const char* argv0, CustomPrefixCallback prefix_callback, - void* prefix_callback_data) { - if (prefix_callback != nullptr) { - g_prefix_formatter = std::make_unique( - prefix_callback, prefix_callback_data); - } else { - g_prefix_formatter = nullptr; - } - InitGoogleLogging(argv0); -} -#if defined(__GNUG__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER) -# pragma warning(pop) -#endif // __GNUG__ - void InstallPrefixFormatter(PrefixFormatterCallback callback, void* data) { if (callback != nullptr) { g_prefix_formatter = std::make_unique(callback, data);