1#![allow(non_camel_case_types, non_snake_case)]
8
9extern crate libc;
10#[cfg(any(feature = "debug", feature = "trace", feature = "spam"))]
11#[macro_use]
12extern crate log;
13
14mod ffi;
15
16pub use ffi::*;
17
18#[cfg(any(feature = "debug", feature = "trace", feature = "spam"))]
19#[no_mangle]
20unsafe extern "C" fn __duktape_sys_debug_write(
21 _: libc::c_long,
22 file: *const libc::c_char,
23 line: libc::c_long,
24 func: *const libc::c_char,
25 msg: *const libc::c_char,
26) {
27 if log_enabled!(log::Level::Trace) {
28 let file_str = ::std::ffi::CStr::from_ptr(file).to_string_lossy();
29
30 let target = format!("{} {}", module_path!(), file_str);
31 if log_enabled!(target: &target, log::Level::Trace) {
32 let func_str = ::std::ffi::CStr::from_ptr(func).to_string_lossy();
33 let msg_str = ::std::ffi::CStr::from_ptr(msg).to_string_lossy();
34 trace!(
35 target: &target,
36 "{} ({}.{}:{})",
37 msg_str,
38 file_str,
39 func_str,
40 line
41 );
42 }
43 }
44}