Gate the really verbose log messages behind a feature.
Otherwise, trying to use the socket buffers instead of BufReader/ BufWriter is doomed to overwhelm the application logic.v0.7.x
parent
15a344f1d3
commit
34d32f67a2
|
@ -25,4 +25,5 @@ use_std = ["managed/use_std", "libc"]
|
|||
use_alloc = ["managed/use_alloc"]
|
||||
use_collections = ["managed/use_collections"]
|
||||
use_log = ["log"]
|
||||
default = ["use_std", "use_log"]
|
||||
verbose = []
|
||||
default = ["use_std", "use_log", "verbose"]
|
||||
|
|
13
README.md
13
README.md
|
@ -86,6 +86,8 @@ The `use_std` feature enables use of objects and slices owned by the networking
|
|||
dependency on `std::boxed::Box` and `std::vec::Vec`. It also enables `smoltcp::phy::RawSocket`
|
||||
and `smoltcp::phy::TapInterface`, if the platform supports it.
|
||||
|
||||
This feature is enabled by default.
|
||||
|
||||
### Feature `use_alloc`
|
||||
|
||||
The `use_alloc` feature enables use of objects owned by the networking stack through a dependency
|
||||
|
@ -103,6 +105,17 @@ the [log crate][log]. The events are emitted with the TRACE log level.
|
|||
|
||||
[log]: https://crates.io/crates/log
|
||||
|
||||
This feature is enabled by default.
|
||||
|
||||
### Feature `verbose`
|
||||
|
||||
The `verbose` feature enables logging of events where the logging itself may incur very high
|
||||
overhead. For example, emitting a log line every time an application reads or writes as little
|
||||
as 1 octet from a socket is likely to overwhelm the application logic unless a `BufReader`
|
||||
or `BufWriter` is used, which are of course not available on heap-less systems.
|
||||
|
||||
This feature is disabled by default.
|
||||
|
||||
Usage example
|
||||
-------------
|
||||
|
||||
|
|
|
@ -480,6 +480,7 @@ impl<'a> TcpSocket<'a> {
|
|||
let old_length = self.tx_buffer.len();
|
||||
let buffer = self.tx_buffer.enqueue(size);
|
||||
if buffer.len() > 0 {
|
||||
#[cfg(any(test, feature = "verbose"))]
|
||||
net_trace!("[{}]{}:{}: tx buffer: enqueueing {} octets (now {})",
|
||||
self.debug_id, self.local_endpoint, self.remote_endpoint,
|
||||
buffer.len(), old_length + buffer.len());
|
||||
|
@ -515,6 +516,7 @@ impl<'a> TcpSocket<'a> {
|
|||
let buffer = self.rx_buffer.dequeue(size);
|
||||
self.remote_seq_no += buffer.len();
|
||||
if buffer.len() > 0 {
|
||||
#[cfg(any(test, feature = "verbose"))]
|
||||
net_trace!("[{}]{}:{}: rx buffer: dequeueing {} octets (now {})",
|
||||
self.debug_id, self.local_endpoint, self.remote_endpoint,
|
||||
buffer.len(), old_length - buffer.len());
|
||||
|
|
Loading…
Reference in New Issue