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:
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.
In addition to the Console APIs, you can also use any standard Go function that
emits output to stdout
or stderr
. The output from these functions are
available in the runtime logs.
For example, you may use:
fmt.Println
to write to informational messages to the logsfmt.Fprintf(os.Stderr, ...)
to write error messages to the logsYou may also return error
objects from your function, whose messages get
captured and returned in the GraphQL response.
To begin, import the console
package from the SDK:
The APIs in the console
package 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!
Asserts that a condition is true, and logs an error if it’s not.
The boolean condition to assert.
An error message to log, if the assertion is false.
For Go, typically you use these logging APIs when you need detailed control of
the logging level, or when you need to log multi-line messages as a single log
entry. Otherwise, you can use the standard Go functions from the fmt
package
to emit messages to stdout
or stderr
.
Generate a log message, with no particular logging level.
A message you want to log.
Generate a message using Go format specifiers and logs the message, with no particular logging level.
A message you want to log.
Arguments that correspond to the format specifiers in the message.
Generate a log message with the “debug” logging level.
A debug message you want to log.
Generate a message using Go format specifiers and logs the message with the “debug” logging level.
A debug message you want to log.
Arguments that correspond to the format specifiers in the message.
Generate a log message with the “info” logging level.
An informational message you want to log.
Generate a message using Go format specifiers and logs the message with the “info” logging level.
An informational message you want to log.
Arguments that correspond to the format specifiers in the message.
Generate a log message with the “warning” logging level.
A warning message you want to log.
Generate a message using Go format specifiers and logs the message with the “warning” logging level.
A warning message you want to log.
Arguments that correspond to the format specifiers in the message.
Generate a log message with the “error” logging level.
An error message you want to log.
Generate a message using Go format specifiers and logs the message with the “error” logging level.
An error message you want to log.
Arguments that correspond to the format specifiers in the message.
Starts a new timer using the specified label.
An optional label for the timer.
Logs the current value of a timer previously started with console.Time
.
An optional label for the timer.
Logs the current value of a timer previously started with console.Time
, and
discards the timer.
An optional label for the timer.
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:
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.
In addition to the Console APIs, you can also use any standard Go function that
emits output to stdout
or stderr
. The output from these functions are
available in the runtime logs.
For example, you may use:
fmt.Println
to write to informational messages to the logsfmt.Fprintf(os.Stderr, ...)
to write error messages to the logsYou may also return error
objects from your function, whose messages get
captured and returned in the GraphQL response.
To begin, import the console
package from the SDK:
The APIs in the console
package 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!
Asserts that a condition is true, and logs an error if it’s not.
The boolean condition to assert.
An error message to log, if the assertion is false.
For Go, typically you use these logging APIs when you need detailed control of
the logging level, or when you need to log multi-line messages as a single log
entry. Otherwise, you can use the standard Go functions from the fmt
package
to emit messages to stdout
or stderr
.
Generate a log message, with no particular logging level.
A message you want to log.
Generate a message using Go format specifiers and logs the message, with no particular logging level.
A message you want to log.
Arguments that correspond to the format specifiers in the message.
Generate a log message with the “debug” logging level.
A debug message you want to log.
Generate a message using Go format specifiers and logs the message with the “debug” logging level.
A debug message you want to log.
Arguments that correspond to the format specifiers in the message.
Generate a log message with the “info” logging level.
An informational message you want to log.
Generate a message using Go format specifiers and logs the message with the “info” logging level.
An informational message you want to log.
Arguments that correspond to the format specifiers in the message.
Generate a log message with the “warning” logging level.
A warning message you want to log.
Generate a message using Go format specifiers and logs the message with the “warning” logging level.
A warning message you want to log.
Arguments that correspond to the format specifiers in the message.
Generate a log message with the “error” logging level.
An error message you want to log.
Generate a message using Go format specifiers and logs the message with the “error” logging level.
An error message you want to log.
Arguments that correspond to the format specifiers in the message.
Starts a new timer using the specified label.
An optional label for the timer.
Logs the current value of a timer previously started with console.Time
.
An optional label for the timer.
Logs the current value of a timer previously started with console.Time
, and
discards the timer.
An optional label for the timer.