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
#![no_std]
use js::*;

pub fn clear() {
    js!("function(){
        console.clear(); 
    }")
    .invoke_0();
}

pub fn log(msg: &str) {
    js!("function(strPtr,strLen){
        console.log(this.readUtf8FromMemory(strPtr,strLen)); 
    }")
    .invoke_2(msg.as_ptr() as u32, msg.len() as u32);
}

pub fn warning(msg: &str) {
    js!("function(strPtr,strLen){
        console.warn(this.readUtf8FromMemory(strPtr,strLen)); 
    }")
    .invoke_2(msg.as_ptr() as u32, msg.len() as u32);
}

pub fn error(msg: &str) {
    js!("function(strPtr,strLen){
        console.error(this.readUtf8FromMemory(strPtr,strLen)); 
    }")
    .invoke_2(msg.as_ptr() as u32, msg.len() as u32);
}

pub fn time(msg: &str) {
    js!("function(strPtr,strLen){
        console.time(this.readUtf8FromMemory(strPtr,strLen)); 
    }")
    .invoke_2(msg.as_ptr() as u32, msg.len() as u32);
}

pub fn time_end(msg: &str) {
    js!("function(strPtr,strLen){
        console.timeEnd(this.readUtf8FromMemory(strPtr,strLen)); 
    }")
    .invoke_2(msg.as_ptr() as u32, msg.len() as u32);
}