From 8b93894fc5e319c774fb41b57e2d9690b5cda194 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 20 Apr 2023 18:18:25 +0200 Subject: [PATCH] Log loaned msg error only once --- r2r/src/publishers.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/r2r/src/publishers.rs b/r2r/src/publishers.rs index b0a399c..2c0f0b9 100644 --- a/r2r/src/publishers.rs +++ b/r2r/src/publishers.rs @@ -3,6 +3,7 @@ use std::ffi::CString; use std::fmt::Debug; use std::marker::PhantomData; use std::sync::Weak; +use std::sync::Once; use crate::error::*; use crate::msg_types::*; @@ -206,10 +207,12 @@ where ); Ok(msg) } else { - // TODO: Switch to logging library - eprintln!( - "Currently used middleware can't loan messages. Local allocator will be used." - ); + static LOG_LOANED_ERROR: Once = Once::new(); + LOG_LOANED_ERROR.call_once(|| { + // TODO: Switch to logging library + eprintln!("Currently used middleware can't loan messages. Local allocator will be used."); + }); + Ok(WrappedNativeMsg::::new()) } }