f1a00d128e
- 桌面 engine(pion 数据面,承 ab57afd 之后的精修):
- 新增 logging.go——把 pion 内部日志路由到宿主 OnLog(真机无 stderr,连接失败无从查);仅 ice/mdns 作用域放 Debug、余 Info+、Trace 丢弃,按 session 聚合
- wire.go / session.go / engine.go:进度回调 ~10Hz 节流(progressEmitThrottleMs,高吞吐下每片一回调打满宿主主线程;终态由 emitProgressNow 强发最终值),与 web store push 同量级;engine_test.go 跟进
- web 数据面路由:p2p.ts 翻 IOS_NATIVE=true(iOS 走原生 libwebrtc 引擎)+ 新增 p2pIos.ts(iOS p2p 后端)+ p2pNative.ts / net/ios.ts 跟进
- 数据面设计文档 NATIVE-TRANSFER.md:U1(gomobile+pion)真机证伪 → 翻案 U2(libwebrtc)的依据与实测证据(§7/§8)
- 线协议三端一致(cdrop-file ordered / meta+chunk(64KB)+done+ack / 16MB-4MB 水位 / ack 追平完成),桌面 pion ↔ iOS libwebrtc ↔ web JS 互通
64 lines
2.0 KiB
Go
64 lines
2.0 KiB
Go
package engine
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/pion/logging"
|
|
)
|
|
|
|
// emitLoggerFactory 把 pion 内部日志路由到宿主 OnLog——真机上无 stderr,否则「为何连不上」无从查。
|
|
// 只在连接建立相关作用域(ice / mdns)放开 Debug(候选对检查、ping 失败、sendto 权限错误等关键线索),
|
|
// 其余作用域仅 Info 及以上,避免数据面(sctp/dtls)刷屏。Trace 一律丢弃(过量)。
|
|
type emitLoggerFactory struct {
|
|
emit func(string)
|
|
sessionID string
|
|
}
|
|
|
|
func (f emitLoggerFactory) NewLogger(scope string) logging.LeveledLogger {
|
|
return emitLogger{scope: scope, emit: f.emit, sessionID: f.sessionID}
|
|
}
|
|
|
|
type emitLogger struct {
|
|
scope string
|
|
sessionID string
|
|
emit func(string)
|
|
}
|
|
|
|
// fwd 统一以 "session <id> ..." 起头,与 session.go 的诊断行同格式,便于宿主按 session 聚合日志。
|
|
func (l emitLogger) fwd(level, msg string) {
|
|
if l.emit != nil {
|
|
l.emit(fmt.Sprintf("session %s pion %s/%s: %s", l.sessionID, l.scope, level, msg))
|
|
}
|
|
}
|
|
|
|
// debugOn 仅对连接建立作用域放开 Debug,限制日志量。
|
|
func (l emitLogger) debugOn() bool { return l.scope == "ice" || l.scope == "mdns" }
|
|
|
|
func (l emitLogger) Trace(string) {}
|
|
func (l emitLogger) Tracef(string, ...interface{}) {}
|
|
|
|
func (l emitLogger) Debug(msg string) {
|
|
if l.debugOn() {
|
|
l.fwd("D", msg)
|
|
}
|
|
}
|
|
|
|
func (l emitLogger) Debugf(format string, args ...interface{}) {
|
|
if l.debugOn() {
|
|
l.fwd("D", fmt.Sprintf(format, args...))
|
|
}
|
|
}
|
|
|
|
func (l emitLogger) Info(msg string) { l.fwd("I", msg) }
|
|
func (l emitLogger) Infof(format string, args ...interface{}) {
|
|
l.fwd("I", fmt.Sprintf(format, args...))
|
|
}
|
|
func (l emitLogger) Warn(msg string) { l.fwd("W", msg) }
|
|
func (l emitLogger) Warnf(format string, args ...interface{}) {
|
|
l.fwd("W", fmt.Sprintf(format, args...))
|
|
}
|
|
func (l emitLogger) Error(msg string) { l.fwd("E", msg) }
|
|
func (l emitLogger) Errorf(format string, args ...interface{}) {
|
|
l.fwd("E", fmt.Sprintf(format, args...))
|
|
}
|