[GN] Finish BUILD.gn file for logger

Also, fix logger build when depending on proto_lite
Bonus: ran gn format on build files.

Change-Id: Ie00b39d3733402564f6f23e221a0cb553afda653
diff --git a/config/BUILD.gn b/config/BUILD.gn
index 085588c..3716ec0 100644
--- a/config/BUILD.gn
+++ b/config/BUILD.gn
@@ -4,6 +4,10 @@
 
 import("//third_party/protobuf/proto_library.gni")
 
+config("proto_config") {
+  defines = [ "PROTO_LITE" ]
+}
+
 proto_library("cobalt_config_proto") {
   proto_in_dir = "//third_party/cobalt"
   sources = [
@@ -11,6 +15,7 @@
     "encodings.proto",
     "metric_definition.proto",
     "metrics.proto",
+    "project.proto",
     "report_configs.proto",
     "report_definition.proto",
     "window_size.proto",
@@ -24,7 +29,10 @@
     "//third_party/cobalt:cobalt_proto",
   ]
 
-  extra_configs = [ "//third_party/cobalt:cobalt_config" ]
+  extra_configs = [
+    ":proto_config",
+    "//third_party/cobalt:cobalt_config",
+  ]
 }
 
 static_library("client_config") {
diff --git a/logger/BUILD.gn b/logger/BUILD.gn
index 969327d..5fb3070 100644
--- a/logger/BUILD.gn
+++ b/logger/BUILD.gn
@@ -2,15 +2,25 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+source_set("status") {
+  sources = [
+    "status.h",
+  ]
+}
+
 source_set("project_context") {
   sources = [
     "project_context.cc",
     "project_context.h",
   ]
 
-  public_configs = [ "//third_party/cobalt:cobalt_config" ]
+  public_configs = [
+    "//third_party/cobalt:cobalt_config",
+    "//third_party/cobalt/config:proto_config",
+  ]
 
   public_deps = [
+    ":status",
     "//garnet/public/lib/fxl",
     "//third_party/cobalt/config:cobalt_config_proto",
   ]
@@ -25,6 +35,8 @@
   public_configs = [ "//third_party/cobalt:cobalt_config" ]
 
   public_deps = [
+    ":project_context",
+    ":status",
     "//garnet/public/lib/fxl",
     "//third_party/abseil-cpp",
     "//third_party/cobalt/config:cobalt_config_proto",
@@ -40,8 +52,22 @@
   public_configs = [ "//third_party/cobalt:cobalt_config" ]
 
   public_deps = [
+    ":status",
     "//garnet/public/lib/fxl",
-    "//third_party/cobalt/config:cobalt_config_proto",
+    "//third_party/cobalt:cobalt_proto",
+  ]
+}
+
+source_set("logger_interface") {
+  sources = [
+    "logger_interface.h",
+  ]
+
+  public_configs = [ "//third_party/cobalt:cobalt_config" ]
+
+  public_deps = [
+    ":encoder",
+    ":status",
   ]
 }
 
@@ -53,9 +79,12 @@
 
   public_configs = [ "//third_party/cobalt:cobalt_config" ]
 
-  deps = [
+  public_deps = [
     ":encoder",
+    ":logger_interface",
     ":observation_writer",
     ":project_context",
+    ":status",
+    "//third_party/cobalt/config:id",
   ]
 }
diff --git a/logger/encoder.cc b/logger/encoder.cc
index 0f367e8..8569eb5 100644
--- a/logger/encoder.cc
+++ b/logger/encoder.cc
@@ -88,7 +88,7 @@
     default:
       LOG(ERROR) << "Invalid Cobalt config: Report " << report->report_name()
                  << " for metric " << metric.metric_name() << " in project "
-                 << metric.project().DebugString()
+                 << metric.ProjectDebugString()
                  << " does not have local_privacy_noise_level set to a "
                     "recognized value.";
       result.status = kInvalidConfig;
@@ -108,7 +108,7 @@
       LOG(ERROR) << "BasicRapporEncoder returned kInvalidConfig for: Report "
                  << report->report_name() << " for metric "
                  << metric.metric_name() << " in project "
-                 << metric.project().DebugString() << ".";
+                 << metric.ProjectDebugString() << ".";
       result.status = kInvalidConfig;
       return result;
 
@@ -116,7 +116,7 @@
       LOG(ERROR) << "BasicRapporEncoder returned kInvalidInput for: Report "
                  << report->report_name() << " for metric "
                  << metric.metric_name() << " in project "
-                 << metric.project().DebugString() << ".";
+                 << metric.ProjectDebugString() << ".";
       result.status = kInvalidArguments;
       return result;
   }
@@ -186,7 +186,7 @@
     default:
       LOG(ERROR) << "Invalid Cobalt config: Report " << report->report_name()
                  << " for metric " << metric.metric_name() << " in project "
-                 << metric.project().DebugString()
+                 << metric.ProjectDebugString()
                  << " does not have local_privacy_noise_level set to a "
                     "recognized value.";
       result.status = kInvalidConfig;
@@ -204,7 +204,7 @@
       LOG(ERROR) << "RapporEncoder returned kInvalidConfig for: Report "
                  << report->report_name() << " for metric "
                  << metric.metric_name() << " in project "
-                 << metric.project().DebugString() << ".";
+                 << metric.ProjectDebugString() << ".";
       result.status = kInvalidConfig;
       return result;
 
@@ -212,7 +212,7 @@
       LOG(ERROR) << "RapporEncoder returned kInvalidInput for: Report "
                  << report->report_name() << " for metric "
                  << metric.metric_name() << " in project "
-                 << metric.project().DebugString() << ".";
+                 << metric.ProjectDebugString() << ".";
       result.status = kInvalidArguments;
       return result;
   }
@@ -229,7 +229,7 @@
   if (report->threshold() < 2) {
     LOG(ERROR) << "Invalid Cobalt config: Report " << report->report_name()
                << " for metric " << metric.metric_name() << " in project "
-               << metric.project().DebugString()
+               << metric.ProjectDebugString()
                << " has an invalid value for |threshold|.";
     result.status = kInvalidConfig;
     return result;
@@ -251,7 +251,7 @@
       LOG(ERROR) << "ForculusEncrypter returned kInvalidConfig for: Report "
                  << report->report_name() << " for metric "
                  << metric.metric_name() << " in project "
-                 << metric.project().DebugString() << ".";
+                 << metric.ProjectDebugString() << ".";
       result.status = kInvalidConfig;
       return result;
 
@@ -259,7 +259,7 @@
       LOG(ERROR) << "ForculusEncrypter returned kEncryptionFailed for: Report "
                  << report->report_name() << " for metric "
                  << metric.metric_name() << " in project "
-                 << metric.project().DebugString() << ".";
+                 << metric.ProjectDebugString() << ".";
       result.status = kOther;
   }
   return result;
@@ -279,7 +279,7 @@
     LOG(ERROR) << "Hashing the component name failed for: Report "
                << report->report_name() << " for metric "
                << metric.metric_name() << " in project "
-               << metric.project().DebugString() << ".";
+               << metric.ProjectDebugString() << ".";
     result.status = kOther;
   }
   integer_event_observation->set_value(value);
@@ -299,7 +299,7 @@
     LOG(ERROR) << "Hashing the component name failed for: Report "
                << report->report_name() << " for metric "
                << metric.metric_name() << " in project "
-               << metric.project().DebugString() << ".";
+               << metric.ProjectDebugString() << ".";
     result.status = kOther;
   }
   histogram_observation->mutable_buckets()->Swap(histogram.get());
diff --git a/logger/project_context.cc b/logger/project_context.cc
index e1f1406..234c1a3 100644
--- a/logger/project_context.cc
+++ b/logger/project_context.cc
@@ -23,6 +23,14 @@
 
 const Project& MetricRef::project() const { return *project_; }
 
+const std::string MetricRef::ProjectDebugString() const {
+#ifdef PROTO_LITE
+  return project_->project_name();
+#else
+  return project_->DebugString();
+#endif
+}
+
 uint32_t MetricRef::metric_id() const { return metric_definition_->id(); }
 
 const std::string& MetricRef::metric_name() const {
@@ -93,5 +101,13 @@
   return MetricRef(&project_, metric_definition);
 }
 
+const std::string ProjectContext::DebugString() const {
+#ifdef PROTO_LITE
+  return project_.project_name();
+#else
+  return project_.DebugString();
+#endif
+}
+
 }  // namespace logger
 }  // namespace cobalt
diff --git a/logger/project_context.h b/logger/project_context.h
index 005ec6c..4211fc2 100644
--- a/logger/project_context.h
+++ b/logger/project_context.h
@@ -30,6 +30,7 @@
   MetricRef(const Project* project, const MetricDefinition* metric_definition);
 
   const Project& project() const;
+  const std::string ProjectDebugString() const;
   uint32_t metric_id() const;
   const std::string& metric_name() const;
 
@@ -57,7 +58,7 @@
 
   const Project& project() const { return project_; }
 
-  const std::string DebugString() const { return project_.DebugString(); }
+  const std::string DebugString() const;
 
  private:
   Project project_;