While each Modus SDK offers similar capabilities, the APIs and usage may vary between languages.

Modus Console APIs documentation is available on the following pages:

The Modus Console APIs allow 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 namespace is globally available by default in all AssemblyScript functions, you don’t need to import it.

The Console APIs mimic 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. Please 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.

function assert<T>(assertion: T, message?: string): void
assertion
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.

function log(message?: string): void
message
string

A message you want to log.

debug

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

function debug(message?: string): void
message
string

A debug message you want to log.

info

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

function info(message?: string): void
message
string

An informational message you want to log.

warn

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

function warn(message?: string): void
message
string

A warning message you want to log.

error

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

function error(message?: string): void
message
string

An error message you want to log.

Timing Functions

time

Starts a new timer using the specified label.

function 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.

function 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.

function timeEnd(label?: string): void
label
string

An optional label for the timer.