Allow StatsLog to directly write to statsd's socket.

+ Reuse the log_event_list from liblog. StatsLog's binary format remains unchanged
+ Copied socket write code from liblog, including the retry logic.
+ Added build flags to control the StatsLog channel (logd, statsd, or both for debugging)

Bug: 78239479
Test: locally tested and saw logs being written to statsd

Change-Id: I7b1f0069ead00bbf3c29e4bd5b7f363a7ce26abe
diff --git a/cmds/statsd/statsd.rc b/cmds/statsd/statsd.rc
index 3a0c224..f349292 100644
--- a/cmds/statsd/statsd.rc
+++ b/cmds/statsd/statsd.rc
@@ -14,6 +14,7 @@
 
 service statsd /system/bin/statsd
     class main
+    socket statsdw dgram+passcred 0222 statsd statsd
     user statsd
     group statsd log
     writepid /dev/cpuset/system-background/tasks