lesswriter.go 396 B

12345678910111213141516171819202122
  1. package logx
  2. import "io"
  3. type lessWriter struct {
  4. *limitedExecutor
  5. writer io.Writer
  6. }
  7. func newLessWriter(writer io.Writer, milliseconds int) *lessWriter {
  8. return &lessWriter{
  9. limitedExecutor: newLimitedExecutor(milliseconds),
  10. writer: writer,
  11. }
  12. }
  13. func (w *lessWriter) Write(p []byte) (n int, err error) {
  14. w.logOrDiscard(func() {
  15. w.writer.Write(p)
  16. })
  17. return len(p), nil
  18. }