diff --git a/app/src/main/java/com/geeksville/mesh/NodeInfo.kt b/app/src/main/java/com/geeksville/mesh/NodeInfo.kt index e6e5f236c..fdd8bf6ef 100644 --- a/app/src/main/java/com/geeksville/mesh/NodeInfo.kt +++ b/app/src/main/java/com/geeksville/mesh/NodeInfo.kt @@ -6,6 +6,14 @@ import com.geeksville.mesh.ui.bearing import com.geeksville.mesh.ui.latLongToMeter +/** + * When printing strings to logs sometimes we want to print useful debugging information about users + * or positions. But we don't want to leak things like usernames or locations. So this function + * if given a string, will return a string which is a maximum of three characters long, taken from the tail + * of the string. Which should effectively hide real usernames and locations, but still let us see if values were zero or empty. + */ +val Any.anonymized: String get() = this.toString().takeLast(3) + "..." + // model objects that directly map to the corresponding protobufs data class MeshUser(val id: String, val longName: String, val shortName: String) : Parcelable { @@ -35,6 +43,10 @@ data class MeshUser(val id: String, val longName: String, val shortName: String) return arrayOfNulls(size) } } + + override fun toString(): String { + return "MeshUser(id=${id.anonymized}, longName=${longName.anonymized}, shortName=${shortName.anonymized})" + } } data class Position( @@ -78,6 +90,10 @@ data class Position( return arrayOfNulls(size) } } + + override fun toString(): String { + return "Position(lat=${latitude.anonymized}, lon=${longitude.anonymized}, alt=${altitude.anonymized}, time=${time})" + } }