Debug Mode
Understand how to use gill's debug mode to more easily debug your Solana applications.
Within gill
, you can enable "debug mode" to automatically log additional information that will be
helpful in troubleshooting your Solana applications (especially failing transactions).
Debug mode is disabled by default to minimize additional logs for your application. But with its flexible debug controller, you can enable it from the most common places your code will be run. Including your code itself, NodeJS backends, serverless functions, and even the in web browser console itself.
Some examples of the existing debug logs that gill
has sprinkled in:
- log the Solana Explorer link for transactions as you are sending them via
sendAndConfirmTransaction
- log the base64 transaction string for further troubleshooting using
mucho inspect
or the Solana Explorer's Transaction Inspector
How to enable debug mode
To enable debug mode, set any of the following to true
or 1
:
process.env.GILL_DEBUG
global.__GILL_DEBUG__
window.__GILL_DEBUG__
(i.e. in your web browser's console)- or manually set any debug log level (see below)
Pro Tip
Set the GILL_DEBUG
environment variable in your applications' preview/staging environments to
improve your logging and troubleshooting workflows.
How to set a debug level
To set a desired level of logs to be output in your application, set the value of one of the
following (default: info
):
process.env.GILL_DEBUG_LEVEL
global.__GILL_DEBUG_LEVEL__
window.__GILL_DEBUG_LEVEL__
(i.e. in your web browser's console)
The log levels supported (in order of priority):
debug
(lowest)info
(default)warn
error
Custom debug logs
Gill also exports the same debug functions it uses internally, allowing you to implement your own
debug logic related to your Solana application and use the same controller for it as gill
does.
These functions include:
isDebugEnabled()
- check if debug mode is enabled or notdebug()
- print debug message if the set log level is reached