#log #logger #logging #wasm

x-log

Convenient log that support Native and WebAssembly

19 unstable releases (3 breaking)

Uses new Rust 2021

0.4.2 May 12, 2022
0.4.1 May 12, 2022
0.3.8 Apr 22, 2022
0.2.4 Apr 16, 2022
0.1.1 Apr 13, 2022

#95 in Debugging

Download history 63/week @ 2022-04-08 124/week @ 2022-04-15 183/week @ 2022-04-22 133/week @ 2022-04-29 168/week @ 2022-05-06 365/week @ 2022-05-13

883 downloads per month

MIT license

19KB
328 lines

Log for both native and wasm

common log functionality

  • outputs:
    2022-04-15 02:09:50 test:7 [T]: This is an example message
    

print value functionality

  • print values to console conveniently like this:

    val!(v1, v2, v3);

    output:

    2022-04-21 22:19:59 val_print:26 
    v1︎︎︎︎⏤►[1, 2, 3]
    v2︎︎︎︎⏤►[4, 5, 6]
    v3︎︎︎︎⏤►"i am a string"
    
  • or all in one line

    valn!(v1, v2, v3);

    them output:

    2022-04-21 22:19:59 val_print:23 v1︎︎︎︎⏤►[1, 2, 3], n︎︎︎︎⏤►3, v2︎︎︎︎⏤►[4, 5, 6]
    
  • or with pretty format

    valf!(v1);

    output:

    2022-04-22 22:00:32 val_print:12 
    pos︎︎︎︎⏤►Position {
      x: 3.234,
      y: -1.223,
    }
    

usage

use x_log::*;

fn main() {
  info!("This is an example message.");
}

or with config

use x_log::*;

fn main() {
  // not necessary
  x_log::init_once(Some(Options {
    level: LevelFilter::Debug,
    print_level: true,
    timezone: Timezone::Local,
    colored: true,
    ..Default::default()
  }));
  
  let v1 = "123";
  let v2 = vec![4,5,6];
  
  info!("print some values below.");
  val!(v1, v2);
}

wasm

If you want to use it in wasm, enable feature wasm.

Dependencies

~0.8–2.9MB
~52K SLoC