Crate stderr [] [src]

stderr

A library that using macro to write to io::stderr() like print!()/println!().

Usage

On Cargo.toml:

  [dependencies]
  stderr = "0.6.1"

or

  [dependencies]
  poolite = { git = "https://github.com/biluohc/stderr",branch = "master", version = "0.6.1" }

About stderr

Usage as same as print!/println!.

  1. err!/errln!: Panics if writing to io::stderr() fails.
  2. errst!/errstln!: Do nothing if writing to io::stderr() fails(silent->st).

About stderr::Loger

db!()/dbln!()/dbst!()/dbstln!() print message while args conntains -log or --log(follows as module_path!(), if it has no followers,will print the message them occurred on current crate.)

or environment variable 'LOG' as module_path!().

Example for bash(if crate'name is 'app'):

   env LOG=app  app_file_path
   env LOG=     app_file_path
   env LOG=app::mod1         app_file_path
   env LOG=app::mod1::mod2   app_file_path

   app_file_path --log app
   app_file_path --log
   app_file_path --log app::mod1
   app_file_path --log app::mod1::mod2

If you neend to use db!(),dbln!() ,etc:

You must use init!() before use them on the current process.

Example

#[macro_use]
extern crate stderr;

fn main() {
  println!("err!/errln!/errst!/errstln!()@stderr !");
  let vec = vec![1, 2, 3, 4, 5];
  let s = std::env::args().nth(0).unwrap();

  err!("err!(expr\\n)\n");
  err!("err!(String: vec![1, 2, 3, 4, 5])\n{}: {:?}", s, vec);
  errln!();
  errln!("errln!(expr)");

  println!();

  errst!("errst!(expr\\n)\n");
  errst!("errst!(String: vec![1, 2, 3, 4, 5])\n{}: {:?}", s, vec);
  errstln!();
  errstln!("errstln!(expr)");

  // If you need to use `dbxxx!`,you must run `init!()` before use them on current process.
  // Otherwise you should ignore the following.

  use stderr::Loger;  // `dbxxx!` belongs the module.
  init!();
  dbln!();
  dbln!("db!/dbln!()@Loger !");
  db!("{}\n", s);
  dbln!("{:?}", vec);

  dbstln!();
  dbstln!("dbst!/dbstln!()@Loger !");
  dbst!("{}\n", s);
  dbstln!("{:?}", vec);
}

Macros

db
dbln
dbst
dbstln
err
errln
errst
errstln
init

Structs

Loger