1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#[macro_export]
macro_rules! debug {
($($arg:tt)+) => {
let message = format!($($arg)+);
let message = format!("[{}] {}", std::module_path!(), message);
$crate::log::print_debug(message);
};
}
#[macro_export]
macro_rules! error {
($($arg:tt)+) => {
let message = format!($($arg)+);
let message = format!("[{}] {}", std::module_path!(), message);
$crate::log::print_error(message);
};
}
#[macro_export]
macro_rules! info {
($($arg:tt)+) => {
let message = format!($($arg)+);
let message = format!("[{}] {}", std::module_path!(), message);
$crate::log::print_info(message);
};
}
#[macro_export]
macro_rules! trace {
($($arg:tt)+) => {
let message = format!($($arg)+);
let message = format!("[{}] {}", std::module_path!(), message);
$crate::log::print_trace(message);
};
}
#[macro_export]
macro_rules! warn {
($($arg:tt)+) => {
let message = format!($($arg)+);
let message = format!("[{}] {}", std::module_path!(), message);
$crate::log::print_warn(message);
};
}
#[cfg(all(not(feature = "__test"), not(feature = "host")))]
pub fn print_debug(message: String) {
crate::shim::write_err(message);
unsafe { host_debug() };
}
#[cfg(all(not(feature = "__test"), not(feature = "host")))]
pub fn print_error(message: String) {
crate::shim::write_err(message);
unsafe { host_error() };
}
#[cfg(all(not(feature = "__test"), not(feature = "host")))]
pub fn print_info(message: String) {
crate::shim::write_err(message);
unsafe { host_info() };
}
#[cfg(all(not(feature = "__test"), not(feature = "host")))]
pub fn print_trace(message: String) {
crate::shim::write_err(message);
unsafe { host_trace() };
}
#[cfg(all(not(feature = "__test"), not(feature = "host")))]
pub fn warn(message: String) {
crate::shim::write_err(message);
unsafe { host_warn() };
}
#[cfg(all(not(feature = "__test"), not(feature = "host")))]
#[link(wasm_import_module = "tanoshi")]
extern "C" {
fn host_debug();
fn host_error();
fn host_info();
fn host_trace();
fn host_warn();
}
#[cfg(any(feature = "__test", feature = "host"))]
pub fn print_debug(message: String) {
log::debug!(target: "extension", "{}", message);
}
#[cfg(any(feature = "__test", feature = "host"))]
pub fn print_error(message: String) {
log::error!(target: "extension", "{}", message);
}
#[cfg(any(feature = "__test", feature = "host"))]
pub fn print_info(message: String) {
log::info!(target: "extension", "{}", message);
}
#[cfg(any(feature = "__test", feature = "host"))]
pub fn print_trace(message: String) {
log::trace!(target: "extension", "{}", message);
}
#[cfg(any(feature = "__test", feature = "host"))]
pub fn print_warn(message: String) {
log::warn!(target: "extension", "{}", message);
}