Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
Advanced Usage

Debugging


The @blocklet/server-js client uses the popular debug library for logging. Enabling these logs can help you troubleshoot issues by providing detailed information about the GraphQL queries and mutations being sent to the Blocklet Server, as well as other internal client activities.

Enabling Logs in Node.js#

To view debug output in a Node.js environment, set the DEBUG environment variable when running your application. The logs will be printed to the standard error stream.

Basic Logging#

To enable logs specifically for the Blocklet Server Client:

DEBUG=@blocklet/server-js node your-script.js

Replace your-script.js with the entry point of your application.

Verbose Logging#

If you need to see logs from the client and its underlying dependencies (like the GraphQL request library), you can use a wildcard:

DEBUG=@blocklet/server-js* node your-script.js

This can be useful for diagnosing network-level issues.

Enabling Logs in the Browser#

To enable debugging in a web browser, you can use the browser's developer console to set a key in localStorage.

  1. Open your application in the browser.
  2. Open the developer tools (usually with F12 or Cmd+Option+I).
  3. Go to the "Console" tab.
  4. Execute the following command:
localStorage.setItem('DEBUG', '@blocklet/server-js')
  1. Refresh the page.

After refreshing, the debug output will appear in the console, showing you the client's activity.

To disable the logs, you can remove the item:

localStorage.removeItem('DEBUG')

Understanding the Debug Output#

The debug logs provide a clear view of the GraphQL requests and responses.

A typical log entry will look like this:

@blocklet/server-js request: { query: '{ blocklets { list { did name description } } }', variables: {} } +0ms
@blocklet/server-js response: { data: { blocklets: { list: [ ... ] } } } +123ms

Here's a breakdown of the components:

Component

Description

@blocklet/server-js

The namespace of the logger, identifying the source of the log.

request / response

Indicates whether the log entry is for an outgoing request or an incoming response.

{...}

The JSON payload, containing the GraphQL query and variables for a request, or the data for a response.

+123ms

The time elapsed since the previous debug message from any namespace, which helps in performance analysis.

With debugging enabled, you can effectively trace API calls and troubleshoot unexpected behavior. If you plan to contribute to the client, please see our Development guide.