Skip to content

Commit

Permalink
include log crate and change println to log macros
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBelgum authored and Jeff Belgum committed Mar 2, 2017
1 parent 90deda5 commit b175b57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntp"
version = "0.1.1"
version = "0.1.2"
authors = ["Jeff Belgum <jeffbelgum@gmail.com>"]
license = "MIT/Apache-2.0"
description = "Library for parsing and communicating over Network Time Protocol."
Expand All @@ -16,4 +16,5 @@ byteorder = "0.5.3"
conv = "0.3.2"
custom_derive = "0.1.5"
error-chain = "0.5.0"
log = "0.3.6"
time = "0.1.35"
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn main() {
#[macro_use] extern crate custom_derive;
#[macro_use] extern crate conv;
#[macro_use] extern crate error_chain;
#[macro_use] extern crate log;
extern crate byteorder;
extern crate time;

Expand All @@ -38,12 +39,12 @@ pub fn request<A: ToSocketAddrs>(addr: A) -> errors::Result<packet::Packet> {
sock.set_read_timeout(Some(Duration::from_secs(5)))?;
sock.set_write_timeout(Some(Duration::from_secs(5)))?;
let sz = sock.send_to(&data, addr)?;
println!("{:?}", sock.local_addr());
println!("sent: {}", sz);
debug!("{:?}", sock.local_addr());
debug!("sent: {}", sz);
let mut buf = vec![0; 48];
let res = sock.recv(&mut buf)?;
println!("recv: {:?}", res);
println!("{:?}", &buf[..]);
debug!("recv: {:?}", res);
debug!("{:?}", &buf[..]);
let rdr = Cursor::new(&buf);
return Ok(packet::Packet::try_from(rdr)?);
}
Expand Down
2 changes: 1 addition & 1 deletion src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct Packet {

impl Packet {
pub fn new_client() -> Packet {
println!("{}", TimestampFormat::from(time::now().to_timespec()));
trace!("{}", TimestampFormat::from(time::now().to_timespec()));
Packet {
mode: Mode::Client,
vn: Version::Ver2,
Expand Down

0 comments on commit b175b57

Please sign in to comment.