The Modus Console API allows you to capture information from your functions, such as errors and other information that can help you debug your functions.

Unlike other APIs, the Console API is globally available by default in all functions, you don’t need to import it.

The Console API mimics the behavior of the AssemblyScript 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.error is also sent to the GraphQL response.
  • Errors thrown with the throw keyword are also sent to the GraphQL response.

Console APIs

The APIs in the console namespace are below, organized by category.

We’re constantly introducing new APIs through ongoing development with early users. Open an issue if you have ideas on what would make Modus even more powerful for your next app!

Assertion Functions

assert

Asserts that a condition is true, and logs an error if it’s not.

console.assert(assertion: any, message?: string): void
assertion
any
required

The condition to assert. Typically a boolean value. In the case of an object, asserts that the object isn’t null.

message
string

An error message to log, if the assertion is false.

Logging Functions

log

Generate a log message, with no particular logging level.

console.log(message?: string): void
message
string

A message you want to log.

debug

Generate a log message with the “debug” logging level.

console.debug(message?: string): void
message
string

A debug message you want to log.

info

Generate a log message with the “info” logging level.

console.info(message?: string): void
message
string

An informational message you want to log.

warn

Generate a log message with the “warning” logging level.

console.warn(message?: string): void
message
string

A warning message you want to log.

error

Generate a log message with the “error” logging level.

console.error(message?: string): void
message
string

An error message you want to log.

Timing Functions

time

Starts a new timer using the specified label.

console.time(label?: string): void
label
string

An optional label for the timer.

timeLog

Logs the current value of a timer previously started with console.time.

console.timeLog(label?: string): void
label
string

An optional label for the timer.

timeEnd

Logs the current value of a timer previously started with console.time, and discards the timer.

console.timeEnd(label?: string): void
label
string

An optional label for the timer.