internal/mobileinit: send iOS logs to ASL
Fixes golang/go#12194 Change-Id: I9ff771336996c19ca43da56e3f8944e79c980a2b Reviewed-on: https://go-review.googlesource.com/13703 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
e959dea03d
commit
ab223cffc9
38
internal/mobileinit/mobileinit_ios.go
Normal file
38
internal/mobileinit/mobileinit_ios.go
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin
|
||||
// +build arm arm64
|
||||
|
||||
package mobileinit
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
/*
|
||||
#include <asl.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void asl_log_wrap(const char *str) {
|
||||
asl_log(NULL, NULL, ASL_LEVEL_NOTICE, str);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
type aslWriter struct{}
|
||||
|
||||
func (aslWriter) Write(p []byte) (n int, err error) {
|
||||
cstr := C.CString(string(p))
|
||||
C.asl_log_wrap(cstr)
|
||||
C.free(unsafe.Pointer(cstr))
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.SetOutput(io.MultiWriter(os.Stderr, aslWriter{}))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user