Преглед изворни кода

Make the log crate properly optional.

whitequark пре 7 година
родитељ
комит
d5f11159d8
4 измењених фајлова са 8 додато и 5 уклоњено
  1. 1 0
      .test_like_travis.rb
  2. 1 0
      examples/stress.rs
  3. 1 2
      src/lib.rs
  4. 5 3
      src/socket/tcp.rs

+ 1 - 0
.test_like_travis.rb

@@ -11,5 +11,6 @@ travis_config['matrix']['include'].each do |env|
   travis_config['script'].each do |cmd|
     $stderr.puts('+ ' + cmd.gsub(/\$(\w+)/) { ENV[$1] })
     system(cmd)
+    $?.success? or exit 1
   end
 end

+ 1 - 0
examples/stress.rs

@@ -1,4 +1,5 @@
 #[cfg(feature = "log")]
+#[macro_use]
 extern crate log;
 #[cfg(feature = "log")]
 extern crate env_logger;

+ 1 - 2
src/lib.rs

@@ -83,8 +83,7 @@ extern crate std;
 extern crate libc;
 #[cfg(feature = "alloc")]
 extern crate alloc;
-#[cfg(any(test, feature = "log"))]
-#[allow(unused_imports)]
+#[cfg(feature = "log")]
 #[macro_use(log, trace, debug)]
 extern crate log;
 

+ 5 - 3
src/socket/tcp.rs

@@ -1555,12 +1555,12 @@ mod test {
             payload_len: repr.buffer_len(),
             hop_limit:   64
         };
-        trace!("send: {}", repr);
+        net_trace!("send: {}", repr);
 
         assert!(socket.accepts(&ip_repr, repr));
         match socket.process(timestamp, &ip_repr, repr) {
             Ok(Some((_ip_repr, repr))) => {
-                trace!("recv: {}", repr);
+                net_trace!("recv: {}", repr);
                 Ok(Some(repr))
             }
             Ok(None) => Ok(None),
@@ -1580,7 +1580,7 @@ mod test {
             assert_eq!(ip_repr.dst_addr(), REMOTE_IP);
             assert_eq!(ip_repr.payload_len(), tcp_repr.buffer_len());
 
-            trace!("recv: {}", tcp_repr);
+            net_trace!("recv: {}", tcp_repr);
             Ok(f(Ok(tcp_repr)))
         });
         match result {
@@ -1637,6 +1637,7 @@ mod test {
         })
     }
 
+    #[cfg(feature = "log")]
     fn init_logger() {
         extern crate log;
         use std::boxed::Box;
@@ -1662,6 +1663,7 @@ mod test {
     }
 
     fn socket() -> TcpSocket<'static> {
+        #[cfg(feature = "log")]
         init_logger();
 
         let rx_buffer = SocketBuffer::new(vec![0; 64]);