Skip to content

Commit

Permalink
feat: remove deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Feb 20, 2024
1 parent 5a7856a commit 7ce276b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 195 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
73 changes: 4 additions & 69 deletions src/glog/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}
Expand All @@ -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_; }

Expand All @@ -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
Expand Down Expand Up @@ -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();

Expand All @@ -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*);

Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
125 changes: 1 addition & 124 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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:
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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<PrefixFormatter>(
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<PrefixFormatter>(callback, data);
Expand Down

0 comments on commit 7ce276b

Please sign in to comment.