github.com/provpn/mobile@v0.0.0-20210315122651-28c475f89f6c/internal/mobileinit/mobileinit_ios.go (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build darwin && (arm || arm64) 6 // +build darwin 7 // +build arm arm64 8 9 package mobileinit 10 11 import ( 12 "io" 13 "log" 14 "os" 15 "unsafe" 16 ) 17 18 /* 19 #include <asl.h> 20 #include <stdlib.h> 21 22 void asl_log_wrap(const char *str) { 23 asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "%s", str); 24 } 25 */ 26 import "C" 27 28 type aslWriter struct{} 29 30 func (aslWriter) Write(p []byte) (n int, err error) { 31 cstr := C.CString(string(p)) 32 C.asl_log_wrap(cstr) 33 C.free(unsafe.Pointer(cstr)) 34 return len(p), nil 35 } 36 37 func init() { 38 log.SetOutput(io.MultiWriter(os.Stderr, aslWriter{})) 39 }