Browse Source

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.
whitequark 8 years ago
parent
commit
874d192f8a
3 changed files with 17 additions and 1 deletions
  1. 2 1
      Cargo.toml
  2. 13 0
      README.md
  3. 2 0
      src/socket/tcp.rs

+ 2 - 1
Cargo.toml

@@ -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 - 0
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
 -------------
 

+ 2 - 0
src/socket/tcp.rs

@@ -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());