mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Access NSLog through Cgo for iOS NetworkExtension logging
This commit is contained in:
parent
6bbd8c1b30
commit
87362a21e2
4 changed files with 32 additions and 3 deletions
25
src/yggdrasil/mobile_ios.go
Normal file
25
src/yggdrasil/mobile_ios.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
// +build mobile,darwin
|
||||
|
||||
package yggdrasil
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -x objective-c
|
||||
#cgo LDFLAGS: -framework Foundation
|
||||
#import <Foundation/Foundation.h>
|
||||
void Log(const char *text) {
|
||||
NSString *nss = [NSString stringWithUTF8String:text];
|
||||
NSLog(@"%@", nss);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type MobileLogger struct {
|
||||
}
|
||||
|
||||
func (nsl MobileLogger) Write(p []byte) (n int, err error) {
|
||||
p = append(p, 0)
|
||||
cstr := (*C.char)(unsafe.Pointer(&p[0]))
|
||||
C.Log(cstr)
|
||||
return len(p), nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue