Methods
log()
Output to log with log level Info. Internally use util.format for create output, so
format chars can be used:
- %s - String.
- %d - Number (both integer and float).
- %j - JSON.
% - single percent sign ('%'). This does not consume an argument.
console.log('%s is a %s usually with weight less then %dgr', 'apple', 'fruit', 100);
//Will output "apple is a fruit usually with weight less then 100gr"
console.log('apple', 'fruit', 100);
//will output "apple fruit 100"
console.log('the object JSON is %j', {a: 12, b: {inner: 11}});
// will output a JSON object instead of [object Object]
Arguments:
-
... (*)
debug()
Output to log with log level Debug. In case process.isDebug is false - do nothing
Arguments:
-
... (*)
info()
Output to log with log level Info (alias for console.log)
Arguments:
-
... (*)
warn()
Output to log with log level Warning. In case of OS console echo output to stderr
Arguments:
-
... (*)
error()
Output to log with log level Error. In case of OS console echo output to stderr
Arguments:
-
... (*)
dir(object)
Uses util.inspect on obj and prints resulting string to stdout.
Arguments:
-
object (Object)
time(label)
Mark a time.
Arguments:
-
label (String)
timeEnd(label)
Finish timer, record output
Arguments:
-
label (string)
Example
console.time('100-elements');
for (var i = 0; i < 100; i++) {
;
}
console.timeEnd('100-elements');
assert(expression)
Similar to assert#ok, but the error message is formatted as util.format(message...).
Arguments:
-
expression
Output to log with log level Info. Internally use util.format for create output, so
format chars can be used:
- %s - String.
- %d - Number (both integer and float).
- %j - JSON.
% - single percent sign ('%'). This does not consume an argument.
console.log('%s is a %s usually with weight less then %dgr', 'apple', 'fruit', 100); //Will output "apple is a fruit usually with weight less then 100gr"
console.log('apple', 'fruit', 100); //will output "apple fruit 100"
console.log('the object JSON is %j', {a: 12, b: {inner: 11}}); // will output a JSON object instead of [object Object]
... (*)
Debug. In case process.isDebug is false - do nothing
... (*)
Info (alias for console.log)
... (*)
Warning. In case of OS console echo output to stderr
... (*)
Error. In case of OS console echo output to stderr
... (*)
object (Object)
label (String)
label (string)
console.time('100-elements');
for (var i = 0; i < 100; i++) {
;
}
console.timeEnd('100-elements');assert#ok, but the error message is formatted as util.format(message...).
expression