github.com/yaling888/clash@v1.53.0/log/log_std.go (about) 1 package log 2 3 import ( 4 "bytes" 5 "errors" 6 "log" 7 8 logger "github.com/phuslu/log" 9 ) 10 11 func init() { 12 log.SetFlags(0) 13 log.SetOutput(&stdWriter{}) 14 } 15 16 type stdWriter struct{} 17 18 func (hl *stdWriter) Write(p []byte) (n int, err error) { 19 n = len(p) 20 if n < 2 { 21 return 22 } 23 s := "[STD]" 24 i := bytes.IndexByte(p, ':') 25 if i == -1 { 26 i = 0 27 } else { 28 s += " " + string(p[:i]) 29 i = min(i+2, n-2) 30 } 31 logger.Info().Err(errors.New(string(p[i : n-1]))).Msg(s) 32 return 33 }