diff --git a/src/google/protobuf/compiler/python/generator.cc b/src/google/protobuf/compiler/python/generator.cc index 151f81c95c..91f17626eb 100644 --- a/src/google/protobuf/compiler/python/generator.cc +++ b/src/google/protobuf/compiler/python/generator.cc @@ -51,8 +51,9 @@ #include #include -#include "google/protobuf/stubs/logging.h" #include "absl/container/flat_hash_map.h" +#include "google/protobuf/stubs/logging.h" +#include "google/protobuf/stubs/logging.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -167,7 +168,7 @@ std::string StringifyDefaultValue(const FieldDescriptor& field) { } // (We could add a default case above but then we wouldn't get the nice // compiler warning when a new type is added.) - GOOGLE_LOG(FATAL) << "Not reached."; + GOOGLE_ABSL_LOG(FATAL) << "Not reached."; return ""; } @@ -179,8 +180,9 @@ std::string StringifySyntax(FileDescriptor::Syntax syntax) { return "proto3"; case FileDescriptor::SYNTAX_UNKNOWN: default: - GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports proto2 " - "and proto3 syntax."; + GOOGLE_ABSL_LOG(FATAL) + << "Unsupported syntax; this generator only supports proto2 " + "and proto3 syntax."; return ""; } } @@ -290,7 +292,7 @@ bool Generator::Generate(const FileDescriptor* file, } std::unique_ptr output(context->Open(filename)); - GOOGLE_CHECK(output.get()); + GOOGLE_ABSL_CHECK(output.get()); io::Printer printer(output.get(), '$'); printer_ = &printer; @@ -947,7 +949,7 @@ std::string Generator::FieldReferencingExpression( const std::string& python_dict_name) const { // We should only ever be looking up fields in the current file. // The only things we refer to from other files are message descriptors. - GOOGLE_CHECK_EQ(field.file(), file_) + GOOGLE_ABSL_CHECK_EQ(field.file(), file_) << field.file()->name() << " vs. " << file_->name(); if (!containing_type) { return ResolveKeyword(field.name()); @@ -1013,7 +1015,7 @@ void Generator::FixForeignFieldsInExtensions() const { void Generator::FixForeignFieldsInExtension( const FieldDescriptor& extension_field) const { - GOOGLE_CHECK(extension_field.is_extension()); + GOOGLE_ABSL_CHECK(extension_field.is_extension()); absl::flat_hash_map m; // Confusingly, for FieldDescriptors that happen to be extensions, @@ -1228,7 +1230,7 @@ void Generator::PrintSerializedPbInterval(const DescriptorT& descriptor, std::string sp; proto.SerializeToString(&sp); int offset = file_descriptor_serialized_.find(sp); - GOOGLE_CHECK_GE(offset, 0); + GOOGLE_ABSL_CHECK_GE(offset, 0); printer_->Print( "_globals['$name$']._serialized_start=$serialized_start$\n" diff --git a/src/google/protobuf/compiler/python/helpers.cc b/src/google/protobuf/compiler/python/helpers.cc index e58ed9ccc8..2a129f1a7f 100644 --- a/src/google/protobuf/compiler/python/helpers.cc +++ b/src/google/protobuf/compiler/python/helpers.cc @@ -32,6 +32,7 @@ #include +#include "google/protobuf/stubs/logging.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" #include "absl/strings/str_replace.h" diff --git a/src/google/protobuf/compiler/python/plugin_unittest.cc b/src/google/protobuf/compiler/python/plugin_unittest.cc index b613f2df7e..54cad05f8c 100644 --- a/src/google/protobuf/compiler/python/plugin_unittest.cc +++ b/src/google/protobuf/compiler/python/plugin_unittest.cc @@ -39,6 +39,7 @@ #include "google/protobuf/compiler/python/generator.h" #include "google/protobuf/testing/googletest.h" #include +#include "google/protobuf/stubs/logging.h" #include "absl/strings/str_split.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" @@ -78,19 +79,19 @@ class TestGenerator : public CodeGenerator { TEST(PythonPluginTest, ImportTest) { // Create files test1.proto and test2.proto with the former importing the // latter. - GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/test1.proto", - "syntax = \"proto3\";\n" - "package foo;\n" - "import \"test2.proto\";" - "message Message1 {\n" - " Message2 message_2 = 1;\n" - "}\n", - true)); - GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/test2.proto", - "syntax = \"proto3\";\n" - "package foo;\n" - "message Message2 {}\n", - true)); + GOOGLE_ABSL_CHECK_OK(File::SetContents(TestTempDir() + "/test1.proto", + "syntax = \"proto3\";\n" + "package foo;\n" + "import \"test2.proto\";" + "message Message1 {\n" + " Message2 message_2 = 1;\n" + "}\n", + true)); + GOOGLE_ABSL_CHECK_OK(File::SetContents(TestTempDir() + "/test2.proto", + "syntax = \"proto3\";\n" + "package foo;\n" + "message Message2 {}\n", + true)); compiler::CommandLineInterface cli; cli.SetInputsAreProtoPathRelative(true); @@ -105,8 +106,8 @@ TEST(PythonPluginTest, ImportTest) { // Loop over the lines of the generated code and verify that we find an // ordinary Python import but do not find the string "importlib". std::string output; - GOOGLE_CHECK_OK(File::GetContents(TestTempDir() + "/test1_pb2.py", &output, - true)); + GOOGLE_ABSL_CHECK_OK(File::GetContents(TestTempDir() + "/test1_pb2.py", &output, + true)); std::vector lines = absl::StrSplit(output, "\n"); std::string expected_import = "import test2_pb2"; bool found_expected_import = false; diff --git a/src/google/protobuf/compiler/python/pyi_generator.cc b/src/google/protobuf/compiler/python/pyi_generator.cc index 607a054534..a239a7840f 100644 --- a/src/google/protobuf/compiler/python/pyi_generator.cc +++ b/src/google/protobuf/compiler/python/pyi_generator.cc @@ -34,6 +34,8 @@ #include #include "absl/container/flat_hash_set.h" +#include "google/protobuf/stubs/logging.h" +#include "google/protobuf/stubs/logging.h" #include "absl/strings/ascii.h" #include "absl/strings/match.h" #include "absl/strings/str_split.h" @@ -384,7 +386,7 @@ std::string PyiGenerator::GetFieldType( return name; } default: - GOOGLE_LOG(FATAL) << "Unsupported field type."; + GOOGLE_ABSL_LOG(FATAL) << "Unsupported field type."; } return ""; } @@ -599,7 +601,7 @@ bool PyiGenerator::Generate(const FileDescriptor* file, } std::unique_ptr output(context->Open(filename)); - GOOGLE_CHECK(output.get()); + GOOGLE_ABSL_CHECK(output.get()); GeneratedCodeInfo annotations; io::AnnotationProtoCollector annotation_collector( &annotations);