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
#![allow(non_camel_case_types, non_snake_case)]
extern crate libc;
#[cfg(any(feature = "debug", feature = "trace", feature = "spam"))]
#[macro_use]
extern crate log;
mod ffi;
pub use ffi::*;
#[cfg(any(feature = "debug", feature = "trace", feature = "spam"))]
#[no_mangle]
unsafe extern "C" fn __duktape_sys_debug_write(
_: libc::c_long,
file: *const libc::c_char,
line: libc::c_long,
func: *const libc::c_char,
msg: *const libc::c_char,
) {
if log_enabled!(log::Level::Trace) {
let file_str = ::std::ffi::CStr::from_ptr(file).to_string_lossy();
let target = format!("{} {}", module_path!(), file_str);
if log_enabled!(target: &target, log::Level::Trace) {
let func_str = ::std::ffi::CStr::from_ptr(func).to_string_lossy();
let msg_str = ::std::ffi::CStr::from_ptr(msg).to_string_lossy();
trace!(
target: &target,
"{} ({}.{}:{})",
msg_str,
file_str,
func_str,
line
);
}
}
}