[][src]Macro stdweb::console

macro_rules! console {
    ( log, $( $args:expr ),+ ) => { ... };
    ( error, $( $args:expr ),+ ) => { ... };
}

Calls methods on the JavaScript console object.

This should only be used for debugging purposes, its behavior is not standardized: it will vary with different browsers and Node.js.

The first argument is the name of the console method.

The remaining arguments can be anything which can be sent to JavaScript, and they do not need to be the same type.

If you want to print things to the console in a standardized way, use println! instead.

(JavaScript docs)

Examples

log

Print a newline:

console!(log, "");

Print one value:

console!(log, "Hello world!");

Print more than one value:

console!(log, 1, "test", vec![2, 3]);

Use string substitution to control how the values are printed:

console!(log, "foo: %s bar: %s", vec![1, 2], vec![3, 4]);

(JavaScript docs)

error

This is exactly the same as log, except it prints an error message rather than a normal message.

(JavaScript docs)