Skip to content

Commit

Permalink
优化crashed日志
Browse files Browse the repository at this point in the history
  • Loading branch information
snail007 committed Sep 14, 2018
1 parent 18716cb commit 7bb5bb8
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 63 deletions.
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func initConfig() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
Expand All @@ -442,7 +442,7 @@ func initConfig() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for scanner.Scan() {
Expand All @@ -452,7 +452,7 @@ func initConfig() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for scannerStdErr.Scan() {
Expand Down
2 changes: 1 addition & 1 deletion core/dst/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (c *Conn) start() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
c.reader()
Expand Down
2 changes: 1 addition & 1 deletion core/dst/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewMux(conn net.PacketConn, packetSize int) *Mux {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
m.readerLoop()
Expand Down
2 changes: 1 addition & 1 deletion core/dst/sendbuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func newSendBuffer(m *Mux) *sendBuffer {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:", e, string(debug.Stack()))
}
}()
b.writerLoop()
Expand Down
12 changes: 6 additions & 6 deletions core/lib/mapx/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (m ConcurrentMap) Iter() <-chan Tuple {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
fanIn(chans, ch)
Expand All @@ -174,7 +174,7 @@ func (m ConcurrentMap) IterBuffered() <-chan Tuple {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
fanIn(chans, ch)
Expand All @@ -195,7 +195,7 @@ func snapshot(m ConcurrentMap) (chans []chan Tuple) {
go func(index int, shard *ConcurrentMapShared) {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
// Foreach key, value pair.
Expand All @@ -221,7 +221,7 @@ func fanIn(chans []chan Tuple, out chan Tuple) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
func(ch chan Tuple) {
Expand Down Expand Up @@ -274,7 +274,7 @@ func (m ConcurrentMap) Keys() []string {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
// Foreach shard.
Expand All @@ -284,7 +284,7 @@ func (m ConcurrentMap) Keys() []string {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
func(shard *ConcurrentMapShared) {
Expand Down
8 changes: 4 additions & 4 deletions core/lib/udp/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (s *IOBinder) AliveWithServeConn(srcAddr string, inTCPConn *net.Conn) *IOBi
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
buf := make([]byte, 1)
Expand All @@ -75,7 +75,7 @@ func (s *IOBinder) AliveWithServeConn(srcAddr string, inTCPConn *net.Conn) *IOBi
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
Expand All @@ -96,7 +96,7 @@ func (s *IOBinder) AliveWithClientConn(srcAddr string, outTCPConn *net.Conn) *IO
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
buf := make([]byte, 1)
Expand Down Expand Up @@ -156,7 +156,7 @@ func (s *IOBinder) Run() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
defer func() {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Clean(s *services.Service) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for _ = range signalChan {
Expand Down
4 changes: 2 additions & 2 deletions sdk/android-ios/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s *DNS) InitService() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
Expand Down Expand Up @@ -142,7 +142,7 @@ func (s *DNS) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
log.Printf("dns server on udp %s", *s.cfg.Local)
Expand Down
2 changes: 1 addition & 1 deletion services/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (s *HTTP) InitService() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
//循环检查ssh网络连通性
Expand Down
6 changes: 3 additions & 3 deletions services/mux/mux_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (s *MuxBridge) handler(inConn net.Conn) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
Expand Down Expand Up @@ -292,7 +292,7 @@ func (s *MuxBridge) callback(inConn net.Conn, serverID, key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(stream, inConn)
Expand All @@ -301,7 +301,7 @@ func (s *MuxBridge) callback(inConn net.Conn, serverID, key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(inConn, stream)
Expand Down
10 changes: 5 additions & 5 deletions services/mux/mux_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (s *MuxClient) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", ID)
Expand Down Expand Up @@ -336,7 +336,7 @@ func (s *MuxClient) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
cui.conn.SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
Expand All @@ -355,7 +355,7 @@ func (s *MuxClient) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
Expand Down Expand Up @@ -414,7 +414,7 @@ func (s *MuxClient) ServeConn(inConn *smux.Stream, localAddr, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(outConn, snappy.NewReader(inConn))
Expand All @@ -423,7 +423,7 @@ func (s *MuxClient) ServeConn(inConn *smux.Stream, localAddr, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(snappy.NewWriter(inConn), outConn)
Expand Down
12 changes: 6 additions & 6 deletions services/mux/mux_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (s *MuxServer) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(inConn, snappy.NewReader(outConn))
Expand All @@ -302,7 +302,7 @@ func (s *MuxServer) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
io.Copy(snappy.NewWriter(outConn), inConn)
Expand Down Expand Up @@ -397,7 +397,7 @@ func (s *MuxServer) GetConn(index string) (conn net.Conn, err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
for {
Expand Down Expand Up @@ -457,7 +457,7 @@ func (s *MuxServer) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
Expand Down Expand Up @@ -536,7 +536,7 @@ func (s *MuxServer) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", ID)
Expand Down Expand Up @@ -569,7 +569,7 @@ func (s *MuxServer) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.sc.UDPListener.WriteToUDP(body, uc.srcAddr)
Expand Down
2 changes: 1 addition & 1 deletion services/socks/socks.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (s *Socks) InitService() (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
//循环检查ssh网络连通性
Expand Down
6 changes: 3 additions & 3 deletions services/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (s *TCP) UDPRevecive(key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", key)
Expand Down Expand Up @@ -286,7 +286,7 @@ func (s *TCP) UDPRevecive(key string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
(*cui.conn).SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
Expand All @@ -305,7 +305,7 @@ func (s *TCP) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
Expand Down
12 changes: 6 additions & 6 deletions services/tunnel/tunnel_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (s *TunnelClient) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.ServeUDP(localAddr, ID, serverID)
Expand All @@ -168,7 +168,7 @@ func (s *TunnelClient) Start(args interface{}, log *logger.Logger) (err error) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.ServeConn(localAddr, ID, serverID)
Expand Down Expand Up @@ -324,7 +324,7 @@ func (s *TunnelClient) ServeUDP(localAddr, ID, serverID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
(*item).udpConn.Write(body)
Expand All @@ -335,7 +335,7 @@ func (s *TunnelClient) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
s.log.Printf("udp conn %s connected", ID)
Expand Down Expand Up @@ -365,7 +365,7 @@ func (s *TunnelClient) UDPRevecive(key, ID string) {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
(*cui.conn).SetWriteDeadline(time.Now().Add(time.Millisecond * time.Duration(*s.cfg.Timeout)))
Expand All @@ -384,7 +384,7 @@ func (s *TunnelClient) UDPGCDeamon() {
go func() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("crashed:%s", string(debug.Stack()))
fmt.Printf("crashed, err: %s\nstack:",e, string(debug.Stack()))
}
}()
if s.isStop {
Expand Down
Loading

0 comments on commit 7bb5bb8

Please sign in to comment.