diff options
author | Andy Getzendanner <durandal@google.com> | 2022-11-16 14:47:18 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-11-16 14:48:00 -0800 |
commit | 0c048353d2e7347f148228d785c3f0a8c81e2223 (patch) | |
tree | 2c6c5a87eccd672de83b8c631c8dcd834c54883e /absl | |
parent | ae52431653d1d2815820680d4539e749f53b7bc7 (diff) |
Minor formatting changes in preparation for structured logging...
PiperOrigin-RevId: 489044912
Change-Id: I1657dd60bcfa2d0fb4b889f27f4f237325b73f08
Diffstat (limited to 'absl')
-rw-r--r-- | absl/log/BUILD.bazel | 1 | ||||
-rw-r--r-- | absl/log/CMakeLists.txt | 4 | ||||
-rw-r--r-- | absl/log/internal/BUILD.bazel | 3 | ||||
-rw-r--r-- | absl/log/internal/log_message.cc | 27 | ||||
-rw-r--r-- | absl/log/internal/log_message.h | 18 | ||||
-rw-r--r-- | absl/log/internal/test_actions.cc | 4 | ||||
-rw-r--r-- | absl/log/internal/test_matchers.cc | 1 | ||||
-rw-r--r-- | absl/log/internal/test_matchers.h | 1 | ||||
-rw-r--r-- | absl/log/log_format_test.cc | 19 |
9 files changed, 36 insertions, 42 deletions
diff --git a/absl/log/BUILD.bazel b/absl/log/BUILD.bazel index 261a3384..3e9d1421 100644 --- a/absl/log/BUILD.bazel +++ b/absl/log/BUILD.bazel @@ -322,7 +322,6 @@ cc_test( deps = [ ":log", ":scoped_mock_log", - "//absl/log/internal:config", "//absl/log/internal:test_matchers", "//absl/strings", "//absl/strings:str_format", diff --git a/absl/log/CMakeLists.txt b/absl/log/CMakeLists.txt index 25531209..0bc8a22f 100644 --- a/absl/log/CMakeLists.txt +++ b/absl/log/CMakeLists.txt @@ -145,7 +145,6 @@ absl_cc_library( absl::inlined_vector absl::examine_stack absl::log_internal_append_truncated - absl::log_internal_config absl::log_internal_format absl::log_internal_globals absl::log_internal_log_sink_set @@ -253,7 +252,6 @@ absl_cc_library( DEPS absl::config absl::log_entry - absl::log_internal_config absl::log_severity absl::strings absl::time @@ -295,7 +293,6 @@ absl_cc_library( DEPS absl::config absl::log_entry - absl::log_internal_config absl::log_internal_test_helpers absl::log_severity absl::strings @@ -696,7 +693,6 @@ absl_cc_test( ${ABSL_DEFAULT_LINKOPTS} DEPS absl::log - absl::log_internal_config absl::log_internal_test_matchers absl::scoped_mock_log absl::str_format diff --git a/absl/log/internal/BUILD.bazel b/absl/log/internal/BUILD.bazel index b4eb1df1..4f600753 100644 --- a/absl/log/internal/BUILD.bazel +++ b/absl/log/internal/BUILD.bazel @@ -134,7 +134,6 @@ cc_library( ], deps = [ ":append_truncated", - ":config", ":format", ":globals", ":log_sink_set", @@ -241,7 +240,6 @@ cc_library( copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":config", "//absl/base:config", "//absl/base:core_headers", "//absl/base:log_severity", @@ -276,7 +274,6 @@ cc_library( copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, deps = [ - ":config", ":test_helpers", "//absl/base:config", "//absl/base:core_headers", diff --git a/absl/log/internal/log_message.cc b/absl/log/internal/log_message.cc index 648086e9..8329597e 100644 --- a/absl/log/internal/log_message.cc +++ b/absl/log/internal/log_message.cc @@ -42,7 +42,6 @@ #include "absl/debugging/internal/examine_stack.h" #include "absl/log/globals.h" #include "absl/log/internal/append_truncated.h" -#include "absl/log/internal/config.h" #include "absl/log/internal/globals.h" #include "absl/log/internal/log_format.h" #include "absl/log/internal/log_sink_set.h" @@ -87,8 +86,8 @@ void WriteToStream(const char* data, void* os) { // A write-only `std::streambuf` that writes into an `absl::Span<char>`. // -// This class is responsible for writing a metadata prefix just before the first -// data are streamed in. The metadata are subject to change (cf. +// This class is responsible for writing a metadata prefix just before the +// first data are streamed in. The metadata are subject to change (cf. // `LogMessage::AtLocation`) until then, so we wait as long as possible. // // This class is also responsible for reserving space for a trailing newline @@ -96,7 +95,8 @@ void WriteToStream(const char* data, void* os) { // streamed in. class LogEntryStreambuf final : public std::streambuf { public: - explicit LogEntryStreambuf(absl::Span<char> buf, const absl::LogEntry& entry) + explicit LogEntryStreambuf(absl::Span<char> buf, + const absl::LogEntry& entry) : buf_(buf), entry_(entry), prefix_len_(0), finalized_(false) { // To detect when data are first written, we leave the put area null, // override `overflow`, and check ourselves in `xsputn`. @@ -107,7 +107,8 @@ class LogEntryStreambuf final : public std::streambuf { absl::Span<const char> Finalize() { assert(!finalized_); - // If no data were ever streamed in, this is where we must write the prefix. + // If no data were ever streamed in, this is where we must write the + // prefix. if (pbase() == nullptr) Initialize(); // Here we reclaim the two bytes we reserved. ptrdiff_t idx = pptr() - pbase(); @@ -140,8 +141,8 @@ class LogEntryStreambuf final : public std::streambuf { private: void Initialize() { - // Here we reserve two bytes in our buffer to guarantee `Finalize` space to - // add a trailing "\n\0". + // Here we reserve two bytes in our buffer to guarantee `Finalize` space + // to add a trailing "\n\0". assert(buf_.size() >= 2); setp(buf_.data(), buf_.data() + buf_.size() - 2); if (entry_.prefix()) { @@ -157,7 +158,8 @@ class LogEntryStreambuf final : public std::streambuf { } size_t Append(absl::string_view data) { - absl::Span<char> remaining(pptr(), static_cast<size_t>(epptr() - pptr())); + absl::Span<char> remaining(pptr(), + static_cast<size_t>(epptr() - pptr())); const size_t written = log_internal::AppendTruncated(data, remaining); pbump(static_cast<int>(written)); return written; @@ -202,7 +204,7 @@ LogMessage::LogMessageData::LogMessageData(const char* file, int line, absl::LogSeverity severity, absl::Time timestamp) : extra_sinks_only(false), - streambuf_(absl::MakeSpan(string_buf), entry) { + streambuf_(absl::MakeSpan(string_buf), entry) { entry.full_filename_ = file; entry.base_filename_ = Basename(file); entry.line_ = line; @@ -216,8 +218,7 @@ LogMessage::LogMessageData::LogMessageData(const char* file, int line, LogMessage::LogMessage(const char* file, int line, absl::LogSeverity severity) : data_( absl::make_unique<LogMessageData>(file, line, severity, absl::Now())) - , - stream_(&data_->streambuf_) +, stream_(&data_->streambuf_) { data_->first_fatal = false; data_->is_perror = false; @@ -225,8 +226,8 @@ LogMessage::LogMessage(const char* file, int line, absl::LogSeverity severity) // Legacy defaults for LOG's ostream: stream_.setf(std::ios_base::showbase | std::ios_base::boolalpha); - // `fill('0')` is omitted here because its effects are very different without - // structured logging. Resolution is tracked in b/111310488. + // `fill('0')` is omitted here because its effects are very different + // without structured logging. Resolution is tracked in b/111310488. // This logs a backtrace even if the location is subsequently changed using // AtLocation. This quirk, and the behavior when AtLocation is called twice, diff --git a/absl/log/internal/log_message.h b/absl/log/internal/log_message.h index 992bb630..8868f8c8 100644 --- a/absl/log/internal/log_message.h +++ b/absl/log/internal/log_message.h @@ -37,7 +37,6 @@ #include "absl/base/config.h" #include "absl/base/internal/errno_saver.h" #include "absl/base/log_severity.h" -#include "absl/log/internal/config.h" #include "absl/log/internal/nullguard.h" #include "absl/log/log_entry.h" #include "absl/log/log_sink.h" @@ -234,9 +233,10 @@ class StringifySink final { }; // Note: the following is declared `ABSL_ATTRIBUTE_NOINLINE` -template <typename T, - typename std::enable_if<strings_internal::HasAbslStringify<T>::value, - int>::type> +template < + typename T, + typename std::enable_if<strings_internal::HasAbslStringify<T>::value, + int>::type> LogMessage& LogMessage::operator<<(const T& v) { StringifySink sink(*this); // Replace with public API. @@ -245,9 +245,10 @@ LogMessage& LogMessage::operator<<(const T& v) { } // Note: the following is declared `ABSL_ATTRIBUTE_NOINLINE` -template <typename T, - typename std::enable_if<!strings_internal::HasAbslStringify<T>::value, - int>::type> +template < + typename T, + typename std::enable_if<!strings_internal::HasAbslStringify<T>::value, + int>::type> LogMessage& LogMessage::operator<<(const T& v) { stream_ << log_internal::NullGuard<T>().Guard(v); return *this; @@ -299,7 +300,8 @@ extern template LogMessage& LogMessage::operator<<(const float& v); extern template LogMessage& LogMessage::operator<<(const double& v); extern template LogMessage& LogMessage::operator<<(const bool& v); extern template LogMessage& LogMessage::operator<<(const std::string& v); -extern template LogMessage& LogMessage::operator<<(const absl::string_view& v); +extern template LogMessage& LogMessage::operator<<( + const absl::string_view& v); // `LogMessageFatal` ensures the process will exit in failure after logging this // message. diff --git a/absl/log/internal/test_actions.cc b/absl/log/internal/test_actions.cc index c0d04e18..6c8a7b13 100644 --- a/absl/log/internal/test_actions.cc +++ b/absl/log/internal/test_actions.cc @@ -21,7 +21,6 @@ #include "absl/base/attributes.h" #include "absl/base/config.h" -#include "absl/log/internal/config.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -49,7 +48,8 @@ void WriteEntryToStderr::operator()(const absl::LogEntry& entry) const { << " log_severity: " << entry.log_severity() << "\n" // << " timestamp: " << entry.timestamp() << "\n" // << " text_message: \"" << text_message << "\"\n" // - << " verbosity: " << entry.verbosity() << "\n" // + << " verbosity: " << entry.verbosity() + << "\n" // << "}\n"; } diff --git a/absl/log/internal/test_matchers.cc b/absl/log/internal/test_matchers.cc index 10f4111f..72ca704e 100644 --- a/absl/log/internal/test_matchers.cc +++ b/absl/log/internal/test_matchers.cc @@ -24,7 +24,6 @@ #include "gtest/gtest.h" #include "absl/base/attributes.h" #include "absl/base/config.h" -#include "absl/log/internal/config.h" #include "absl/log/internal/test_helpers.h" #include "absl/strings/string_view.h" #include "absl/time/clock.h" diff --git a/absl/log/internal/test_matchers.h b/absl/log/internal/test_matchers.h index b8179ccc..98cb33d3 100644 --- a/absl/log/internal/test_matchers.h +++ b/absl/log/internal/test_matchers.h @@ -30,7 +30,6 @@ #include "gtest/gtest.h" #include "absl/base/config.h" #include "absl/base/log_severity.h" -#include "absl/log/internal/config.h" #include "absl/log/internal/test_helpers.h" #include "absl/log/log_entry.h" #include "absl/strings/string_view.h" diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc index f88650fe..ad426214 100644 --- a/absl/log/log_format_test.cc +++ b/absl/log/log_format_test.cc @@ -26,7 +26,6 @@ #endif #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "absl/log/internal/config.h" #include "absl/log/internal/test_matchers.h" #include "absl/log/log.h" #include "absl/log/scoped_mock_log.h" @@ -612,8 +611,9 @@ TYPED_TEST(FloatingPointLogFormatTest, NegativeNaN) { test_sink, Send(AllOf( TextMessage(MatchesOstream(comparison_stream)), - TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"), Eq("-nan(ind)"))), - ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "-nan" })pb"))))); + TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"), + Eq("-nan(ind)"))), ENCODED_MESSAGE(EqualsProto(R"pb(value { str: + "-nan" })pb"))))); test_sink.StartCapturingLogs(); LOG(INFO) << value; @@ -1642,19 +1642,20 @@ TEST(ManipulatorLogFormatTest, IOManipsDoNotAffectAbslStringify) { // Tests that verify the behavior when more data are streamed into a `LOG` // statement than fit in the buffer. -// Structured logging scenario is tested in other unit tests since the output is -// significantly different. +// Structured logging scenario is tested in other unit tests since the output +// is significantly different. TEST(OverflowTest, TruncatesStrings) { absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected); - // This message is too long and should be truncated to some unspecified size - // no greater than the buffer size but not too much less either. It should be - // truncated rather than discarded. + // This message is too long and should be truncated to some unspecified + // size no greater than the buffer size but not too much less either. It + // should be truncated rather than discarded. constexpr size_t buffer_size = 15000; EXPECT_CALL(test_sink, Send(TextMessage( - AllOf(SizeIs(AllOf(Ge(buffer_size - 256), Le(buffer_size))), + AllOf(SizeIs(AllOf(Ge(buffer_size - 256), + Le(buffer_size))), Each(Eq('x')))))); test_sink.StartCapturingLogs(); |