This repository has been archived by the owner on May 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export qlogs when the QLOGDIR env variable is set
- Loading branch information
1 parent
506057f
commit 88546e0
Showing
6 changed files
with
105 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.qlog | ||
*.qlog.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package libp2pquic | ||
|
||
import ( | ||
"bufio" | ||
"io" | ||
) | ||
|
||
type bufferedWriteCloser struct { | ||
*bufio.Writer | ||
io.Closer | ||
} | ||
|
||
func newBufferedWriteCloser(writer *bufio.Writer, closer io.Closer) io.WriteCloser { | ||
return &bufferedWriteCloser{ | ||
Writer: writer, | ||
Closer: closer, | ||
} | ||
} | ||
|
||
func (h bufferedWriteCloser) Close() error { | ||
if err := h.Writer.Flush(); err != nil { | ||
return err | ||
} | ||
return h.Closer.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package libp2pquic | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
type nopCloser struct{} | ||
|
||
func (nopCloser) Close() error { return nil } | ||
|
||
var _ = Describe("buffered io.WriteCloser", func() { | ||
It("flushes before closing", func() { | ||
buf := &bytes.Buffer{} | ||
|
||
w := bufio.NewWriter(buf) | ||
wc := newBufferedWriteCloser(w, &nopCloser{}) | ||
wc.Write([]byte("foobar")) | ||
Expect(buf.Len()).To(BeZero()) | ||
Expect(wc.Close()).To(Succeed()) | ||
Expect(buf.String()).To(Equal("foobar")) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters