sc-executor: Improve logging (#10869)

Improves the logging by switching to `tracing` for a better log output. Besides that, it also adds a
trace for the function being executed.
This commit is contained in:
Bastian Köcher
2022-02-16 20:39:22 +01:00
committed by GitHub
parent ba8c882a7a
commit 1a61cd40fa
4 changed files with 45 additions and 37 deletions
+10 -10
View File
@@ -103,23 +103,23 @@ impl VersionedRuntime {
let result = f(&self.module, &mut *instance, self.version.as_ref(), ext);
if let Err(e) = &result {
if new_inst {
log::warn!(
tracing::warn!(
target: "wasm-runtime",
"Fresh runtime instance failed with {}",
e,
error = %e,
"Fresh runtime instance failed",
)
} else {
log::warn!(
tracing::warn!(
target: "wasm-runtime",
"Evicting failed runtime instance: {}",
e,
error = %e,
"Evicting failed runtime instance",
);
}
} else {
*locked = Some(instance);
if new_inst {
log::debug!(
tracing::debug!(
target: "wasm-runtime",
"Allocated WASM instance {}/{}",
index + 1,
@@ -131,7 +131,7 @@ impl VersionedRuntime {
result
},
None => {
log::warn!(target: "wasm-runtime", "Ran out of free WASM instances");
tracing::warn!(target: "wasm-runtime", "Ran out of free WASM instances");
// Allocate a new instance
let mut instance = self.module.new_instance()?;
@@ -259,7 +259,7 @@ impl RuntimeCache {
match result {
Ok(ref result) => {
log::debug!(
tracing::debug!(
target: "wasm-runtime",
"Prepared new runtime version {:?} in {} ms.",
result.version,
@@ -267,7 +267,7 @@ impl RuntimeCache {
);
},
Err(ref err) => {
log::warn!(target: "wasm-runtime", "Cannot create a runtime: {:?}", err);
tracing::warn!(target: "wasm-runtime", error = ?err, "Cannot create a runtime");
},
}