Index: blimp/common/logging.cc |
diff --git a/blimp/common/logging.cc b/blimp/common/logging.cc |
index 24d6060adb37028eca7f1d7933fa481ef8e7c26b..e045076f3aec099c3b12c7ab0ff508269b0aa9b6 100644 |
--- a/blimp/common/logging.cc |
+++ b/blimp/common/logging.cc |
@@ -300,6 +300,45 @@ void ExtractBlobChannelMessageFields(const BlimpMessage& message, |
} |
} |
+// Logs fields from GEOLOCATION messages. |
+void ExtractGeolocationMessageFields(const BlimpMessage& message, |
+ LogFields* output) { |
+ switch (message.geolocation().type_case()) { |
+ case GeolocationMessage::TypeCase::kUpdateListenState: |
+ AddField("subtype", "UPDATE_LISTEN_STATE", output); |
+ AddField("listen_state", |
+ message.geolocation().update_listen_state().listen_state(), |
+ output); |
+ break; |
+ case GeolocationMessage::TypeCase::kRequestRefresh: |
+ AddField("subtype", "REQUEST_REFRESH", output); |
+ break; |
+ case GeolocationMessage::TypeCase::kLocation: |
+ AddField("subtype", "LOCATION", output); |
+ AddField("latitude", message.geolocation().location().latitude(), output); |
Wez
2016/07/12 21:35:12
nit: Take a local const& to message.geolocation.lo
CJ
2016/07/13 21:49:19
Done.
Wez
2016/07/14 01:19:21
nit: I'd suggest taking the reference to location.
CJ
2016/07/14 23:55:08
Any draw back to leaving the location reference in
|
+ AddField("longitude", message.geolocation().location().longitude(), |
+ output); |
+ AddField("altitude", message.geolocation().location().altitude(), output); |
+ AddField("accuracy", message.geolocation().location().accuracy(), output); |
+ AddField("altitude_accuracy", |
+ message.geolocation().location().altitude_accuracy(), output); |
+ AddField("heading", message.geolocation().location().heading(), output); |
+ AddField("speed", message.geolocation().location().speed(), output); |
+ AddField("timestamp_millis", |
+ message.geolocation().location().timestamp_millis(), output); |
+ break; |
+ case GeolocationMessage::TypeCase::kError: |
+ AddField("subtype", "ERROR", output); |
+ AddField("error_code", message.geolocation().error().error_code(), |
+ output); |
+ AddField("error_message", message.geolocation().error().error_message(), |
+ output); |
+ break; |
+ case GeolocationMessage::TypeCase::TYPE_NOT_SET: |
+ break; |
+ } |
+} |
+ |
} // namespace |
std::ostream& operator<<(std::ostream& out, const BlimpMessage& message) { |
@@ -342,6 +381,10 @@ std::ostream& operator<<(std::ostream& out, const BlimpMessage& message) { |
AddField("type", "IME", &fields); |
ExtractImeMessageFields(message, &fields); |
break; |
+ case BlimpMessage::kGeolocation: |
+ AddField("type", "GEOLOCATION", &fields); |
+ ExtractGeolocationMessageFields(message, &fields); |
+ break; |
case BlimpMessage::FEATURE_NOT_SET: |
AddField("type", "<UNKNOWN>", &fields); |
break; |