Use tracing::instrument instead of tracing::span
This commit is contained in:
parent
854098e292
commit
d5c4b84d79
|
@ -17,7 +17,7 @@ use google_home::{traits::OnOff, FullfillmentError, GoogleHome, GoogleHomeDevice
|
||||||
use pollster::FutureExt;
|
use pollster::FutureExt;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
use tracing::{debug, span, trace, Level};
|
use tracing::{debug, trace};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
light_sensor::{self, OnDarkness},
|
light_sensor::{self, OnDarkness},
|
||||||
|
@ -165,11 +165,11 @@ impl Devices {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl OnMqtt for Devices {
|
impl OnMqtt for Devices {
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
async fn on_mqtt(&mut self, message: &rumqttc::Publish) {
|
async fn on_mqtt(&mut self, message: &rumqttc::Publish) {
|
||||||
self.get::<dyn OnMqtt>()
|
self.get::<dyn OnMqtt>()
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.for_each(|(id, listener)| {
|
.for_each(|(id, listener)| {
|
||||||
let _span = span!(Level::TRACE, "on_mqtt").entered();
|
|
||||||
trace!(id, "Handling");
|
trace!(id, "Handling");
|
||||||
listener.on_mqtt(message).block_on();
|
listener.on_mqtt(message).block_on();
|
||||||
})
|
})
|
||||||
|
@ -178,11 +178,11 @@ impl OnMqtt for Devices {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl OnPresence for Devices {
|
impl OnPresence for Devices {
|
||||||
|
#[tracing::instrument(skip(self))]
|
||||||
async fn on_presence(&mut self, presence: bool) {
|
async fn on_presence(&mut self, presence: bool) {
|
||||||
self.get::<dyn OnPresence>()
|
self.get::<dyn OnPresence>()
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.for_each(|(id, device)| {
|
.for_each(|(id, device)| {
|
||||||
let _span = span!(Level::TRACE, "on_presence").entered();
|
|
||||||
trace!(id, "Handling");
|
trace!(id, "Handling");
|
||||||
device.on_presence(presence).block_on();
|
device.on_presence(presence).block_on();
|
||||||
})
|
})
|
||||||
|
@ -191,11 +191,11 @@ impl OnPresence for Devices {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl OnDarkness for Devices {
|
impl OnDarkness for Devices {
|
||||||
|
#[tracing::instrument(skip(self))]
|
||||||
async fn on_darkness(&mut self, dark: bool) {
|
async fn on_darkness(&mut self, dark: bool) {
|
||||||
self.get::<dyn OnDarkness>()
|
self.get::<dyn OnDarkness>()
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.for_each(|(id, device)| {
|
.for_each(|(id, device)| {
|
||||||
let _span = span!(Level::TRACE, "on_darkness").entered();
|
|
||||||
trace!(id, "Handling");
|
trace!(id, "Handling");
|
||||||
device.on_darkness(dark).block_on();
|
device.on_darkness(dark).block_on();
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user