Skip to content

Debugging Tools

Server Side

Console Logs

Logs are crucial for diagnosing and understanding issues in your project. MassiveRealm provides logging functionality that can be accessed through the MassiveRealm Console.

Viewing Logs

Logs are available under Project / Storage / Logs in the MassiveRealm Console. Logs are rotated every 500 lines and are cleared when the application starts.

Log API

You can use the Log API to add custom log messages to help with debugging.

  • $log.info(...args): Logs informational messages.
  • $log.debug(...args): Logs debug messages.
  • $log.error(...args): Logs error messages.

Example:

javascript
$log.info('This is an info message');
$log.debug('This is a debug message');
$log.error('This is an error message');

Real-Time Statistics

Track traffic, requests stats, CCU (concurrent users) in the MassiveRealm Console under Project / Stats.

Client Side

Debug Mode

When initializing the Client, set the debug property to true to enable detailed logging of client-side events and actions.

Logs will be displayed in the browser console.

Example:

javascript
let MRClient = new MassiveRealmClient.Client({
    debug: true,
    url: 'https://your-project-url/',
    publicKey: 'your-public-key',
    // Other configurations
});

Error Handling

Implement error handling in your client and server scripts to catch and log errors for debugging.

Client-Side Example:

javascript
window.MR = new window.MassiveRealmClient.Client({
    onError: function(error) {
        console.error('Client Error:', error);
    },
    // Other configurations
});

Server-Side Example:

javascript
try {
    // Some server-side code
} catch (error) {
    $log.error('Server Error:', error);
}

Best Practices

Test in Development Mode

Make use of the development environment to test and debug your project before deploying it to production.

Development mode has limits but allows you to test ideas without incurring costs.

Use Meaningful Logs

Ensure that your log messages are meaningful and provide enough context to understand the issue without additional information.

Example:

javascript
$log.debug('User login attempt', { username: 'testUser' });

Monitor Performance Metrics

Keep an eye on your project's performance metrics, such as CCU (concurrent users), traffic, and number of requests, to identify potential bottlenecks or issues.

Validate Inputs

MassiveRealm communication is based on binary with raw values only. That means if you defined string in the schema, you should send string values only.

model-field-types.png

Make Batches by using Timers

When you need to update multiple objects, consider batching them to reduce the number of requests and improve performance.

By following these guidelines and using the available debugging tools, you can effectively identify and resolve issues in your MassiveRealm project, ensuring a smooth and robust development process.