github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/readers/reader_print.go (about) 1 // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . 2 3 package readers 4 5 import ( 6 "io" 7 "log" 8 ) 9 10 type PrintReader struct { 11 rawReader io.Reader 12 tag string 13 } 14 15 func NewPrintReader(rawReader io.Reader, tag string) io.Reader { 16 return &PrintReader{ 17 rawReader: rawReader, 18 tag: tag, 19 } 20 } 21 22 func (this *PrintReader) Read(p []byte) (n int, err error) { 23 n, err = this.rawReader.Read(p) 24 if n > 0 { 25 log.Println("[" + this.tag + "]" + string(p[:n])) 26 } 27 return 28 }