MCPcopy Create free account
hub / github.com/dfinity/orbit / logger

Function logger

core/control-panel/impl/src/core/middlewares.rs:21–49  ·  view source on GitHub ↗
(target_fn: &'static str, context: &CallContext, result: Option<&T>)

Source from the content-addressed store, hash-verified

19}
20
21pub fn logger<T>(target_fn: &'static str, context: &CallContext, result: Option<&T>)
22where
23 T: std::fmt::Debug,
24{
25 match result {
26 Some(result) => {
27 ic_cdk::api::print(
28 serde_json::to_string(&LogMessage {
29 function: target_fn.to_string(),
30 message: format!("completed execution with result {result:?}"),
31 timestamp: ic_cdk::api::time(),
32 caller: context.caller().to_text(),
33 })
34 .expect("Failed to serialize log message"),
35 );
36 }
37 None => {
38 ic_cdk::api::print(
39 serde_json::to_string(&LogMessage {
40 function: target_fn.to_string(),
41 message: "started execution".to_string(),
42 timestamp: ic_cdk::api::time(),
43 caller: context.caller().to_text(),
44 })
45 .expect("Failed to serialize log message"),
46 );
47 }
48 }
49}
50
51pub fn use_canister_call_metric<T>(called_method: &str, result: &ApiResult<T>)
52where

Callers

nothing calls this directly

Calls 3

printFunction · 0.85
timeFunction · 0.85
callerMethod · 0.45

Tested by

no test coverage detected