1use super::super::host::abi::*;
2use anyhow::{bail, Result};
3
4#[allow(dead_code)]
5enum LogLevel {
6 Error = 2,
7 Warn,
8 Info,
9 Debug,
10 Trace,
11}
12
13pub fn log_info(str: &str) -> Result<()> {
22 match unsafe { ws_log(LogLevel::Info as _, str.as_bytes().as_ptr(), str.len() as _) } {
23 0 => Ok(()),
24 _ => bail!("fail to log the info"),
25 }
26}
27
28pub fn log_error(str: &str) -> Result<()> {
37 match unsafe {
38 ws_log(
39 LogLevel::Error as _,
40 str.as_bytes().as_ptr(),
41 str.len() as _,
42 )
43 } {
44 0 => Ok(()),
45 _ => bail!("fail to log the error"),
46 }
47}