| // #include <android/log.h> |
| var ctag *C.char = C.CString("com.veyron.runtimes.google.ipc") |
| // androidWriter writes it's output using Android's Log() function. |
| type androidWriter struct { |
| func (aw *androidWriter) Write(p []byte) (n int, err error) { |
| for nlidx := bytes.IndexByte(p, '\n'); nlidx != -1; nlidx = bytes.IndexByte(p, '\n') { |
| aw.buf = append(aw.buf, p[:nlidx]...) |
| aw.buf = append(aw.buf, 0) |
| cstr := (*C.char)(unsafe.Pointer(&aw.buf[0])) |
| C.__android_log_write(C.ANDROID_LOG_INFO, ctag, cstr) |
| aw.buf = append(aw.buf, p...) |
| log.SetOutput(&androidWriter{}) |