mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Add Raw Data Output for bytesLogger
This commit is contained in:
parent
6cb82618a0
commit
91379a42f3
1 changed files with 5 additions and 0 deletions
|
@ -11,6 +11,7 @@ type bytesLogger interface {
|
||||||
AddOutbound(int)
|
AddOutbound(int)
|
||||||
AddInbound(int)
|
AddInbound(int)
|
||||||
ThroughputSummary() string
|
ThroughputSummary() string
|
||||||
|
GetStat() (in int, out int)
|
||||||
}
|
}
|
||||||
|
|
||||||
// bytesNullLogger Default bytesLogger does nothing.
|
// bytesNullLogger Default bytesLogger does nothing.
|
||||||
|
@ -25,6 +26,8 @@ func (b bytesNullLogger) AddInbound(amount int) {}
|
||||||
// ThroughputSummary in bytesNullLogger does nothing
|
// ThroughputSummary in bytesNullLogger does nothing
|
||||||
func (b bytesNullLogger) ThroughputSummary() string { return "" }
|
func (b bytesNullLogger) ThroughputSummary() string { return "" }
|
||||||
|
|
||||||
|
func (b bytesNullLogger) GetStat() (in int, out int) { return -1, -1 }
|
||||||
|
|
||||||
// bytesSyncLogger uses channels to safely log from multiple sources with output
|
// bytesSyncLogger uses channels to safely log from multiple sources with output
|
||||||
// occuring at reasonable intervals.
|
// occuring at reasonable intervals.
|
||||||
type bytesSyncLogger struct {
|
type bytesSyncLogger struct {
|
||||||
|
@ -92,3 +95,5 @@ func (b *bytesSyncLogger) ThroughputSummary() string {
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
return fmt.Sprintf("Traffic throughput (up|down): %d %s|%d %s -- (%d OnMessages, %d Sends, over %d seconds)", inbound, inUnit, outbound, outUnit, b.outEvents, b.inEvents, int(t.Sub(b.start).Seconds()))
|
return fmt.Sprintf("Traffic throughput (up|down): %d %s|%d %s -- (%d OnMessages, %d Sends, over %d seconds)", inbound, inUnit, outbound, outUnit, b.outEvents, b.inEvents, int(t.Sub(b.start).Seconds()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *bytesSyncLogger) GetStat() (in int, out int) { return b.inbound, b.outbound }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue