Console

The Console, like its browser counterpart, exposes API related to logging information to the built-in extension console. An instance is always available via the console global object.

Methods

assert(condition, message, [param1…])

Asserts that an expression evaluates to true. If not, the provided message will used to raise an Error. If additional arguments are provided, they will be formatted as arguments in the same way as log().

clear()

Clears all console messages dispatched from the current extension.

log(message, [param1…])

Logs the provided message to the console. If additional arguments are provided, they will be used as substring formatting for the message using JavaScript substring semantics.

info(message, [param1…])

Logs an informative message to the console. Informative messages are of a lower priority than standard log messages, warnings, or errors, and will never alert the user in any way. This method otherwise behaves very similarly to log().

warn(message, [param1…])

Logs a warning message to the console. Warning messages are of a higher priority than standard log messages, but lower priority than errors, and may alert the user in some way. They should be used to indicate that an operation encountered an unexpected state, but can safely continue. This method otherwise behaves very similarly to log().

error(message, [param1…])

Logs an error message to the console. Error messages are of the highest priority in the console, and may alert the user in some way. They should be used to indicate that an operation encountered an unexpected state and cannot continue. This method otherwise behaves very similarly to log().

group()

Begins a logging group. Multiple calls to this method will increase the nested group level by one, and should be balanced by an equal number of calls to groupEnd().

groupEnd()

Ends the deepest nested logging group. Calls to group() must be balanced by an equal number of calls to this method.

count([label])

Logs the number of times this method has been invoked with the provided label. If no label is provided, this method will log the number of times it has been invoked at the current line.

time(label)

Starts a timer with a provided label. When a call to timeEnd() is made using the same label, the total elapsed duration of the timer in milliseconds will be logged to the console.

timeEnd(label)

Ends the timer with a provided label, logging the total elapsed duration of the timer in milliseconds to the console.

timeStamp([label])

Logs the current elapsed duration of a timer with the provided label to the console, without ending the timer. If no label is provided, this method will log the current elapsed duration of all running timers.

trace()

Outputs a stack trace to the console.