Skip to content

Commit ed6f6ba

Browse files
authored
linera_sdk::service: initialize logging before deserializing query (#2755)
1 parent defdf87 commit ed6f6ba

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

linera-sdk/src/service/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub use self::runtime::ServiceRuntime;
1818
pub use self::test_runtime::MockServiceRuntime;
1919
#[doc(hidden)]
2020
pub use self::wit::export_service;
21-
use crate::{util::BlockingWait, ServiceLogger};
21+
use crate::util::BlockingWait as _;
2222

2323
/// Inside tests, use the [`MockServiceRuntime`] instead of the real [`ServiceRuntime`].
2424
#[cfg(with_testing)]
@@ -41,9 +41,10 @@ macro_rules! service {
4141
/// Mark the service type to be exported.
4242
impl $crate::service::wit::exports::linera::app::service_entrypoints::Guest for $service {
4343
fn handle_query(argument: Vec<u8>) -> Vec<u8> {
44-
use $crate::util::BlockingWait;
44+
use $crate::util::BlockingWait as _;
45+
$crate::ServiceLogger::install();
4546
let request = $crate::serde_json::from_slice(&argument)
46-
.expect("Query is invalid and could not be deserialized");
47+
.unwrap_or_else(|_| panic!("Query {argument:?} is invalid and could not be deserialized"));
4748
let response = $crate::service::run_async_entrypoint(
4849
unsafe { &mut SERVICE },
4950
move |service| service.handle_query(request).blocking_wait(),
@@ -69,8 +70,6 @@ pub fn run_async_entrypoint<Service, Output>(
6970
where
7071
Service: crate::Service,
7172
{
72-
ServiceLogger::install();
73-
7473
let service =
7574
service.get_or_insert_with(|| Service::new(ServiceRuntime::new()).blocking_wait());
7675

0 commit comments

Comments
 (0)