add log function
This commit is contained in:
parent
6c6a4fe4e3
commit
85ebd0cb62
@ -1,10 +1,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
typedef void (*LogListener) (const char* log);
|
||||||
|
extern void setLogListener(LogListener l);
|
||||||
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/fatedier/frp/cmd/frpc/sub"
|
"github.com/fatedier/frp/cmd/frpc/sub"
|
||||||
"github.com/fatedier/frp/cmd/frps/frps"
|
"github.com/fatedier/frp/cmd/frps/frps"
|
||||||
"github.com/fatedier/frp/utils/version"
|
"github.com/fatedier/frp/utils/version"
|
||||||
@ -44,9 +48,14 @@ func Version() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// frpsPath := os.Args[2]
|
frpsPath := os.Args[2]
|
||||||
// RunFrps(C.CString(frpsPath))
|
// RunFrps(C.CString(frpsPath))
|
||||||
// TestFrps(C.CString(frpsPath))
|
// TestFrps(C.CString(frpsPath))
|
||||||
|
println(frpsPath)
|
||||||
|
logLog()
|
||||||
|
|
||||||
|
RunFrps(C.CString(frpsPath))
|
||||||
|
|
||||||
c := make(chan bool)
|
c := make(chan bool)
|
||||||
<-c
|
<-c
|
||||||
}
|
}
|
||||||
|
56
cmd/macFrp/log.go
Normal file
56
cmd/macFrp/log.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <stdio.h>
|
||||||
|
typedef void (*LogListener)(const char* log);
|
||||||
|
|
||||||
|
LogListener logListener;
|
||||||
|
|
||||||
|
void setLogListener(LogListener l) {
|
||||||
|
logListener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
void callback(const char* log) {
|
||||||
|
if (logListener) {
|
||||||
|
logListener(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cListener(const char* log) {
|
||||||
|
printf("%s", log);
|
||||||
|
}
|
||||||
|
|
||||||
|
void testLog() {
|
||||||
|
setLogListener(cListener);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/utils/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var l logForMacListener
|
||||||
|
|
||||||
|
type logForMacListener struct {
|
||||||
|
log.LogListener
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *logForMacListener) Log(log string) {
|
||||||
|
C.callback(C.CString(log))
|
||||||
|
}
|
||||||
|
func (l *logForMacListener) Location() string {
|
||||||
|
location, _ := time.LoadLocation("Local")
|
||||||
|
return location.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
l = logForMacListener{}
|
||||||
|
log.AppendListener(&l)
|
||||||
|
}
|
||||||
|
|
||||||
|
func logLog() {
|
||||||
|
C.testLog()
|
||||||
|
println(C.logListener)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user