Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/google/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/glog/logging.h
#	src/logging.cc
  • Loading branch information
GerHobbelt committed Mar 12, 2024
2 parents 081e39a + 31429d8 commit b373047
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 183 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 @@ -472,7 +472,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
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ their usage, please refer to the `user guide <#user-guide>`__.
Usage in Projects
~~~~~~~~~~~~~~~~~

Assuming that glog was previously `built glog using CMake <#cmake>`__ or
installed using a package manager, you can use the CMake command
:cmake:`find_package` to build against glog in your CMake project as follows:
Assuming that glog was previously `built using CMake <#cmake>`__ or installed
using a package manager, you can use the CMake command :cmake:`find_package` to
build against glog in your CMake project as follows:

.. code:: cmake
Expand Down Expand Up @@ -681,7 +681,7 @@ macro can be used as follows:
Verbose level condition macros ``VLOG_IF``, ``VLOG_EVERY_N`` and
``VLOG_IF_EVERY_N`` behave analogous to ``LOG_IF``, ``LOG_EVERY_N``,
``LOF_IF_EVERY``, but accept a numeric verbosity level as opposed to a
``LOG_IF_EVERY_N``, but accept a numeric verbosity level as opposed to a
severity level.

.. code:: cpp
Expand Down
8 changes: 6 additions & 2 deletions bazel/glog.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,28 @@ def glog_library(with_gflags = 1, **kwargs):
"-DHAVE_SYS_UTSNAME_H",
# For src/utilities.cc.
"-DHAVE_SYS_TIME_H",
# NOTE: users could optionally patch -DHAVE_UNWIND off if
# stacktrace dumping is not needed
"-DHAVE_UNWIND",
# Enable dumping stacktrace upon sigaction.
"-DHAVE_SIGACTION",
# For logging.cc.
"-DHAVE_PREAD",
# -DHAVE_MODE_T prevent repeated typedef mode_t leading
# to emcc compilation failure
"-DHAVE_MODE_T",
"-DHAVE_UNISTD_H",
]

linux_or_darwin_copts = wasm_copts + [
"-DGOOGLE_GLOG_DLL_DECL=__attribute__((visibility(\\\"default\\\")))",
"-DGLOG_NO_EXPORT=__attribute__((visibility(\\\"default\\\")))",
"-DHAVE_MODE_T",
"-DHAVE_POSIX_FADVISE",
"-DHAVE_SSIZE_T",
"-DHAVE_SYS_TYPES_H",
# For src/utilities.cc.
"-DHAVE_SYS_SYSCALL_H",
# For src/logging.cc to create symlinks.
"-DHAVE_UNISTD_H",
"-fvisibility-inlines-hidden",
"-fvisibility=hidden",
]
Expand Down
2 changes: 1 addition & 1 deletion src/glog/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#endif

#if !defined(GLOG_EXPORT)
# error <glog/flags.h> was not included correctly. See the documention for how to consume the library.
# error <glog/flags.h> was not included correctly. See the documentation for how to consume the library.
#endif

#include "glog/platform.h"
Expand Down
2 changes: 1 addition & 1 deletion src/glog/log_severity.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#endif

#if !defined(GLOG_EXPORT)
# error <glog/log_severity.h> was not included correctly. See the documention for how to consume the library.
# error <glog/log_severity.h> was not included correctly. See the documentation for how to consume the library.
#endif

namespace google {
Expand Down
72 changes: 6 additions & 66 deletions src/glog/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#endif

#if !defined(GLOG_EXPORT) || !defined(GLOG_NO_EXPORT)
# error <glog/logging.h> was not included correctly. See the documention for how to consume the library.
# error <glog/logging.h> was not included correctly. See the documentation for how to consume the library.
#endif

#include "glog/flags.h"
Expand All @@ -83,10 +83,6 @@ struct GOOGLE_GLOG_DLL_DECL 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 GOOGLE_GLOG_DLL_DECL 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 GOOGLE_GLOG_DLL_DECL 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.
GOOGLE_GLOG_DLL_DECL 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.
GOOGLE_GLOG_DLL_DECL bool IsGoogleLoggingInitialized();

Expand All @@ -511,6 +464,8 @@ GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();

typedef void (*logging_fail_func_t)();

class LogMessage;

using PrefixFormatterCallback = void (*)(std::ostream&, const LogMessage&,
void*);

Expand All @@ -521,12 +476,8 @@ GLOG_EXPORT void InstallPrefixFormatter(PrefixFormatterCallback callback,
// previously set function.
GLOG_EXPORT logging_fail_func_t InstallFailureFunction(logging_fail_func_t fail_func);

GOOGLE_GLOG_DLL_DECL logging_fail_func_t GetInstalledFailureFunction(void);
GOOGLE_GLOG_DLL_DECL bool HasInstalledCustomFailureFunction(void);

// Enable/Disable old log cleaner.
[[deprecated("Use the type-safe std::chrono::minutes EnableLogCleaner overload instead.")]]
GOOGLE_GLOG_DLL_DECL void EnableLogCleaner(unsigned int overdue_days);
GLOG_EXPORT void EnableLogCleaner(const std::chrono::minutes& overdue);
GOOGLE_GLOG_DLL_DECL void DisableLogCleaner();
GOOGLE_GLOG_DLL_DECL void SetApplicationFingerprint(const std::string& fingerprint);

Expand Down Expand Up @@ -1357,11 +1308,6 @@ class GOOGLE_GLOG_DLL_DECL 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 @@ -1518,7 +1464,7 @@ class GOOGLE_GLOG_DLL_DECL 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);
size_t message_len) = 0;

// Redefine this to implement waiting for
// the sink's logging logic to complete.
Expand Down Expand Up @@ -1633,15 +1579,9 @@ class GOOGLE_GLOG_DLL_DECL 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
2 changes: 1 addition & 1 deletion src/glog/raw_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#endif

#if !defined(GLOG_EXPORT)
# error <glog/raw_logging.h> was not included correctly. See the documention for how to consume the library.
# error <glog/raw_logging.h> was not included correctly. See the documentation for how to consume the library.
#endif

#include "glog/log_severity.h"
Expand Down
2 changes: 1 addition & 1 deletion src/glog/vlog_is_on.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#endif

#if !defined(GLOG_EXPORT)
# error <glog/vlog_is_on.h> was not included correctly. See the documention for how to consume the library.
# error <glog/vlog_is_on.h> was not included correctly. See the documentation for how to consume the library.
#endif

#include "glog/flags.h"
Expand Down
106 changes: 1 addition & 105 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,28 +350,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 @@ -380,44 +358,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 @@ -428,21 +373,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 @@ -2313,19 +2245,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& logmsgtime, const char* message,
size_t message_len) {
(void)severity;
(void)full_filename;
(void)base_filename;
(void)line;
(void)logmsgtime;
(void)message;
(void)message_len;
}

void LogSink::WaitTillSent() {
// noop default
}
Expand Down Expand Up @@ -2834,29 +2753,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 b373047

Please sign in to comment.