Unlike other APIs, the Console API is globally available by default in all
functions, you don’t need to import it.
console object, but
directs the output to Hypermode as follows:
- All console output is available in the runtime logs. When hosting on Hypermode, the logs are available in the “Function Runs” section of the Console UI.
- Output from
console.erroris also sent to the GraphQL response. - Errors thrown with the
throwkeyword are also sent to the GraphQL response.
Console APIs
The APIs in theconsole namespace are below, organized by category.
Assertion Functions
assert
Asserts that a condition is true, and logs an error if it’s not.The condition to assert. Typically a boolean value. In the case of an object,
asserts that the object isn’t
null.An error message to log, if the assertion is false.
Logging Functions
log
Generate a log message, with no particular logging level.A message you want to log.
debug
Generate a log message with the “debug” logging level.A debug message you want to log.
info
Generate a log message with the “info” logging level.An informational message you want to log.
warn
Generate a log message with the “warning” logging level.A warning message you want to log.
error
Generate a log message with the “error” logging level.An error message you want to log.
Timing Functions
time
Starts a new timer using the specified label.An optional label for the timer.
timeLog
Logs the current value of a timer previously started withconsole.time.
An optional label for the timer.
timeEnd
Logs the current value of a timer previously started withconsole.time, and
discards the timer.
An optional label for the timer.