feat: remove deprecations (#1078)
This commit is contained in:
parent
5a7856ab96
commit
ea0748d8df
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required (VERSION 3.22)
|
cmake_minimum_required (VERSION 3.22)
|
||||||
project (glog
|
project (glog
|
||||||
VERSION 0.7.0
|
VERSION 0.8.0
|
||||||
DESCRIPTION "C++ implementation of the Google logging module"
|
DESCRIPTION "C++ implementation of the Google logging module"
|
||||||
HOMEPAGE_URL https://github.com/google/glog
|
HOMEPAGE_URL https://github.com/google/glog
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
@ -466,7 +466,7 @@ if (ANDROID)
|
|||||||
endif (ANDROID)
|
endif (ANDROID)
|
||||||
|
|
||||||
set_target_properties (glog PROPERTIES VERSION ${glog_VERSION})
|
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)
|
if (CYGWIN OR WIN32)
|
||||||
target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES)
|
target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES)
|
||||||
|
|||||||
@ -83,10 +83,6 @@ struct GLOG_EXPORT LogMessageTime {
|
|||||||
LogMessageTime();
|
LogMessageTime();
|
||||||
explicit LogMessageTime(std::chrono::system_clock::time_point now);
|
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 {
|
const std::chrono::system_clock::time_point& when() const noexcept {
|
||||||
return timestamp_;
|
return timestamp_;
|
||||||
}
|
}
|
||||||
@ -100,10 +96,6 @@ struct GLOG_EXPORT LogMessageTime {
|
|||||||
int dayOfWeek() const noexcept { return tm_.tm_wday; }
|
int dayOfWeek() const noexcept { return tm_.tm_wday; }
|
||||||
int dayInYear() const noexcept { return tm_.tm_yday; }
|
int dayInYear() const noexcept { return tm_.tm_yday; }
|
||||||
int dst() const noexcept { return tm_.tm_isdst; }
|
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_; }
|
std::chrono::seconds gmtoffset() const noexcept { return gmtoffset_; }
|
||||||
const std::tm& tm() const noexcept { return tm_; }
|
const std::tm& tm() const noexcept { return tm_; }
|
||||||
|
|
||||||
@ -115,24 +107,6 @@ struct GLOG_EXPORT LogMessageTime {
|
|||||||
std::chrono::seconds gmtoffset_;
|
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
|
} // namespace google
|
||||||
|
|
||||||
// The global value of GOOGLE_STRIP_LOG. All the messages logged to
|
// The global value of GOOGLE_STRIP_LOG. All the messages logged to
|
||||||
@ -482,27 +456,6 @@ namespace google {
|
|||||||
// specified by argv0 in log outputs.
|
// specified by argv0 in log outputs.
|
||||||
GLOG_EXPORT void InitGoogleLogging(const char* argv0);
|
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.
|
// Check if google's logging library has been initialized.
|
||||||
GLOG_EXPORT bool IsGoogleLoggingInitialized();
|
GLOG_EXPORT bool IsGoogleLoggingInitialized();
|
||||||
|
|
||||||
@ -515,6 +468,8 @@ typedef void (*logging_fail_func_t)() __attribute__((noreturn));
|
|||||||
typedef void (*logging_fail_func_t)();
|
typedef void (*logging_fail_func_t)();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class LogMessage;
|
||||||
|
|
||||||
using PrefixFormatterCallback = void (*)(std::ostream&, const LogMessage&,
|
using PrefixFormatterCallback = void (*)(std::ostream&, const LogMessage&,
|
||||||
void*);
|
void*);
|
||||||
|
|
||||||
@ -526,10 +481,6 @@ GLOG_EXPORT void InstallPrefixFormatter(PrefixFormatterCallback callback,
|
|||||||
GLOG_EXPORT logging_fail_func_t
|
GLOG_EXPORT logging_fail_func_t
|
||||||
InstallFailureFunction(logging_fail_func_t fail_func);
|
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.
|
// Enable/Disable old log cleaner.
|
||||||
GLOG_EXPORT void EnableLogCleaner(const std::chrono::minutes& overdue);
|
GLOG_EXPORT void EnableLogCleaner(const std::chrono::minutes& overdue);
|
||||||
GLOG_EXPORT void DisableLogCleaner();
|
GLOG_EXPORT void DisableLogCleaner();
|
||||||
@ -1361,11 +1312,6 @@ class GLOG_EXPORT LogMessage {
|
|||||||
// Must be called without the log_mutex held. (L < log_mutex)
|
// Must be called without the log_mutex held. (L < log_mutex)
|
||||||
static int64 num_messages(int severity);
|
static int64 num_messages(int severity);
|
||||||
|
|
||||||
[[deprecated("Use LogMessage::time() instead.")]] const LogMessageTime&
|
|
||||||
getLogMessageTime() const {
|
|
||||||
return time();
|
|
||||||
}
|
|
||||||
|
|
||||||
LogSeverity severity() const noexcept;
|
LogSeverity severity() const noexcept;
|
||||||
int line() const noexcept;
|
int line() const noexcept;
|
||||||
const std::thread::id& thread_id() 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,
|
virtual void send(LogSeverity severity, const char* full_filename,
|
||||||
const char* base_filename, int line,
|
const char* base_filename, int line,
|
||||||
const LogMessageTime& time, const char* message,
|
const LogMessageTime& time, const char* message,
|
||||||
size_t message_len);
|
size_t message_len) = 0;
|
||||||
// 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);
|
|
||||||
|
|
||||||
// Redefine this to implement waiting for
|
// Redefine this to implement waiting for
|
||||||
// the sink's logging logic to complete.
|
// the sink's logging logic to complete.
|
||||||
@ -1637,15 +1578,9 @@ class GLOG_EXPORT Logger {
|
|||||||
// appropriate by the higher level logging facility. For example,
|
// appropriate by the higher level logging facility. For example,
|
||||||
// textual log messages already contain timestamps, and the
|
// textual log messages already contain timestamps, and the
|
||||||
// file:linenumber header.
|
// 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,
|
virtual void Write(bool force_flush,
|
||||||
const std::chrono::system_clock::time_point& timestamp,
|
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
|
// Flush any buffered messages
|
||||||
virtual void Flush() = 0;
|
virtual void Flush() = 0;
|
||||||
|
|||||||
125
src/logging.cc
125
src/logging.cc
@ -342,28 +342,6 @@ static bool SendEmailInternal(const char* dest, const char* subject,
|
|||||||
|
|
||||||
base::Logger::~Logger() = default;
|
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 {
|
namespace {
|
||||||
|
|
||||||
constexpr std::intmax_t kSecondsInDay = 60 * 60 * 24;
|
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.
|
// Optional user-configured callback to print custom prefixes.
|
||||||
class PrefixFormatter {
|
class PrefixFormatter {
|
||||||
public:
|
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
|
PrefixFormatter(PrefixFormatterCallback callback, void* data) noexcept
|
||||||
: version{V2}, callback_v2{callback}, data{data} {}
|
: version{V2}, callback_v2{callback}, data{data} {}
|
||||||
|
|
||||||
void operator()(std::ostream& s, const LogMessage& message) const {
|
void operator()(std::ostream& s, const LogMessage& message) const {
|
||||||
switch (version) {
|
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:
|
case V2:
|
||||||
callback_v2(s, message, data);
|
callback_v2(s, message, data);
|
||||||
break;
|
break;
|
||||||
@ -420,21 +365,8 @@ class PrefixFormatter {
|
|||||||
PrefixFormatter& operator=(const PrefixFormatter& other) = delete;
|
PrefixFormatter& operator=(const PrefixFormatter& other) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Version { V1, V2 } version;
|
enum Version { V2 } version;
|
||||||
union {
|
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;
|
PrefixFormatterCallback callback_v2;
|
||||||
};
|
};
|
||||||
// User-provided data to pass to the callback:
|
// User-provided data to pass to the callback:
|
||||||
@ -2081,38 +2013,6 @@ void SetLogSymlink(LogSeverity severity, const char* symlink_basename) {
|
|||||||
|
|
||||||
LogSink::~LogSink() = default;
|
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() {
|
void LogSink::WaitTillSent() {
|
||||||
// noop default
|
// noop default
|
||||||
}
|
}
|
||||||
@ -2702,29 +2602,6 @@ void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& /*v*/) {
|
|||||||
|
|
||||||
void InitGoogleLogging(const char* argv0) { InitGoogleLoggingUtilities(argv0); }
|
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) {
|
void InstallPrefixFormatter(PrefixFormatterCallback callback, void* data) {
|
||||||
if (callback != nullptr) {
|
if (callback != nullptr) {
|
||||||
g_prefix_formatter = std::make_unique<PrefixFormatter>(callback, data);
|
g_prefix_formatter = std::make_unique<PrefixFormatter>(callback, data);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user