ArangoDB v3.10 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent stable version.

The console module of the JavaScript API

An implementation of the CommonJS console interface in the ArangoDB JavaScript API

global.console === require('console')

Note: You don’t need to load this module directly. The console object is globally defined throughout ArangoDB and provides access to all functions in this module.

Format Strings

The following format specifiers can be used in format strings, which are accepted by various console methods (look for the format parameter below):

  • %s: string
  • %d, %i: integer number
  • %f: floating point number
  • %o: object (circular references marked with ~)
  • %%: literal percent sign %

Example:

console.log('%s = %i%%', 'value', 20.5) // 'value = 20%'

console.assert

console.assert(expression, [format,] argument1, ...)

Tests that an expression is true. If not, logs a message and throws an exception.

Examples

console.assert(value === "abc", "expected: value === abc, actual:", value);

console.debug

console.debug([format,] argument1, ...)

Formats the arguments according to format and logs the result as debug message. Note that debug messages will only be logged if the server is started with log levels debug or trace.

Examples

console.debug("%s", "this is a test");

console.dir

console.dir(object)

Logs a listing of all properties of the object.

Example usage:

console.dir(myObject);

console.error

console.error([format,] argument1, ...)

Formats the arguments according to format and logs the result as error message.

Example usage:

console.error("error '%s': %s", type, message);

console.getline

console.getline()

Reads in a line from the console and returns it as string.

console.group

console.group([format,] argument1, ...)

Formats the arguments according to format and logs the result as log message. Opens a nested block to indent all future messages sent. Call groupEnd to close the block. Representation of block is up to the platform, it can be an interactive block or just a set of indented sub messages.

Example usage:

console.group("user attributes");
console.log("name", user.name);
console.log("id", user.id);
console.groupEnd();

console.groupCollapsed

console.groupCollapsed([format,] argument1, ...)

Same as console.group.

console.groupEnd

console.groupEnd()

Closes the most recently opened block created by a call to group.

console.info

console.info([format,] argument1, ...)

Formats the arguments according to format and logs the result as info message.

Example usage:

console.info("The %s jumped over %d fences", animal, count);

console.log

console.log([format,] argument1, ...)

Formats the arguments according to format and logs the result as log message. This is an alias for console.info().

console.time

console.time(name)

Creates a new timer under the given name. Call timeEnd with the same name to stop the timer and log the time elapsed.

Example usage:

console.time("mytimer");
...
console.timeEnd("mytimer"); // this will print the elapsed time

console.timeEnd

console.timeEnd(name)

Stops a timer created by a call to time and logs the time elapsed.

console.trace

console.trace()

Logs a stack trace of JavaScript execution at the point where it is called.

console.warn

console.warn([format,] argument1, ...)

Formats the arguments according to format and logs the result as warning message.