mirror of
https://github.com/htrefil/rkvm.git
synced 2024-11-16 07:47:24 +01:00
Improve logging
This commit is contained in:
parent
99d5e39ab1
commit
5aff99e218
3 changed files with 17 additions and 17 deletions
|
@ -150,12 +150,12 @@ pub async fn run(
|
|||
entry.or_insert(writer);
|
||||
|
||||
tracing::info!(
|
||||
"Created new device {} (name {:?}, vendor {}, product {}, version {})",
|
||||
id,
|
||||
name,
|
||||
vendor,
|
||||
product,
|
||||
version
|
||||
id = %id,
|
||||
name = ?name,
|
||||
vendor = %vendor,
|
||||
product = %product,
|
||||
version = %version,
|
||||
"Created new device"
|
||||
);
|
||||
}
|
||||
Update::DestroyDevice { id } => {
|
||||
|
@ -166,7 +166,7 @@ pub async fn run(
|
|||
)));
|
||||
}
|
||||
|
||||
tracing::info!("Destroyed device {}", id);
|
||||
tracing::info!(id = %id, "Destroyed device");
|
||||
}
|
||||
Update::Event { id, event } => {
|
||||
let writer = writers.get_mut(&id).ok_or_else(|| {
|
||||
|
@ -178,7 +178,7 @@ pub async fn run(
|
|||
|
||||
writer.write(&event).await.map_err(Error::Input)?;
|
||||
|
||||
tracing::trace!("Wrote an event to device {}", id);
|
||||
tracing::trace!(id = %id, "Wrote an event to device");
|
||||
}
|
||||
Update::Ping => {
|
||||
let duration = start.elapsed();
|
||||
|
|
|
@ -56,7 +56,7 @@ pub async fn timeout<T: Future<Output = Result<U, Error>>, U>(
|
|||
) -> Result<U, Error> {
|
||||
time::timeout(duration, future)
|
||||
.await
|
||||
.map_err(|err| Error::new(ErrorKind::TimedOut, err))?
|
||||
.map_err(|_| Error::new(ErrorKind::TimedOut, "Message timeout"))?
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -159,7 +159,7 @@ pub async fn run(
|
|||
}
|
||||
}
|
||||
|
||||
tracing::trace!("Wrote an event to device {}", id);
|
||||
tracing::trace!(id = %id, "Wrote an event to device");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,12 +168,12 @@ pub async fn run(
|
|||
let device = &devices[id];
|
||||
|
||||
tracing::info!(
|
||||
"Registered new device {} (name {:?}, vendor {}, product {}, version {})",
|
||||
id,
|
||||
device.name,
|
||||
device.vendor,
|
||||
device.product,
|
||||
device.version
|
||||
id = %id,
|
||||
name = ?device.name,
|
||||
vendor = %device.vendor,
|
||||
product = %device.product,
|
||||
version = %device.version,
|
||||
"Registered new device"
|
||||
);
|
||||
}
|
||||
(id, result) = event => match result {
|
||||
|
@ -257,7 +257,7 @@ pub async fn run(
|
|||
}
|
||||
devices.remove(id);
|
||||
|
||||
tracing::info!("Destroyed device {}", id);
|
||||
tracing::info!(id = %id, "Destroyed device");
|
||||
}
|
||||
Err(err) => return Err(Error::Input(err)),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue