1 Star 1 Fork 0

Midstream/rustpub

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

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.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mid/rustpub.git
git@gitee.com:mid/rustpub.git
mid
rustpub
rustpub
master

搜索帮助