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.
This commit is contained in:
parent
15a344f1d3
commit
34d32f67a2
|
@ -25,4 +25,5 @@ use_std = ["managed/use_std", "libc"]
|
||||||
use_alloc = ["managed/use_alloc"]
|
use_alloc = ["managed/use_alloc"]
|
||||||
use_collections = ["managed/use_collections"]
|
use_collections = ["managed/use_collections"]
|
||||||
use_log = ["log"]
|
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`
|
dependency on `std::boxed::Box` and `std::vec::Vec`. It also enables `smoltcp::phy::RawSocket`
|
||||||
and `smoltcp::phy::TapInterface`, if the platform supports it.
|
and `smoltcp::phy::TapInterface`, if the platform supports it.
|
||||||
|
|
||||||
|
This feature is enabled by default.
|
||||||
|
|
||||||
### Feature `use_alloc`
|
### Feature `use_alloc`
|
||||||
|
|
||||||
The `use_alloc` feature enables use of objects owned by the networking stack through a dependency
|
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
|
[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
|
Usage example
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
@ -480,6 +480,7 @@ impl<'a> TcpSocket<'a> {
|
||||||
let old_length = self.tx_buffer.len();
|
let old_length = self.tx_buffer.len();
|
||||||
let buffer = self.tx_buffer.enqueue(size);
|
let buffer = self.tx_buffer.enqueue(size);
|
||||||
if buffer.len() > 0 {
|
if buffer.len() > 0 {
|
||||||
|
#[cfg(any(test, feature = "verbose"))]
|
||||||
net_trace!("[{}]{}:{}: tx buffer: enqueueing {} octets (now {})",
|
net_trace!("[{}]{}:{}: tx buffer: enqueueing {} octets (now {})",
|
||||||
self.debug_id, self.local_endpoint, self.remote_endpoint,
|
self.debug_id, self.local_endpoint, self.remote_endpoint,
|
||||||
buffer.len(), old_length + buffer.len());
|
buffer.len(), old_length + buffer.len());
|
||||||
|
@ -515,6 +516,7 @@ impl<'a> TcpSocket<'a> {
|
||||||
let buffer = self.rx_buffer.dequeue(size);
|
let buffer = self.rx_buffer.dequeue(size);
|
||||||
self.remote_seq_no += buffer.len();
|
self.remote_seq_no += buffer.len();
|
||||||
if buffer.len() > 0 {
|
if buffer.len() > 0 {
|
||||||
|
#[cfg(any(test, feature = "verbose"))]
|
||||||
net_trace!("[{}]{}:{}: rx buffer: dequeueing {} octets (now {})",
|
net_trace!("[{}]{}:{}: rx buffer: dequeueing {} octets (now {})",
|
||||||
self.debug_id, self.local_endpoint, self.remote_endpoint,
|
self.debug_id, self.local_endpoint, self.remote_endpoint,
|
||||||
buffer.len(), old_length - buffer.len());
|
buffer.len(), old_length - buffer.len());
|
||||||
|
|
Loading…
Reference in New Issue