Console APIs
Capture errors and debugging information in your functions
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:
- AssemblyScript Console APIs (this page)
- Go Console APIs
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.
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 with console.time
.
An optional label for the timer.
timeEnd
Logs the current value of a timer previously started with console.time
, and
discards the timer.
An optional label for the timer.
Was this page helpful?