CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-rollbar

JavaScript error tracking and monitoring library for Node.js and browser environments with telemetry, automatic error grouping, and real-time notifications

Pending
Overview
Eval results
Files

core-logging.mddocs/

Core Logging

Core error and message logging functionality providing multiple severity levels with flexible argument patterns and automatic error enrichment.

Capabilities

Log Method

General purpose logging method that accepts multiple argument types.

/**
 * Log a message or error at the 'log' level
 * @param args - Variable arguments: message, error, object, callback, etc.
 * @returns Object containing the UUID of the logged item
 */
function log(...args: LogArgument[]): LogResult;

Usage Examples:

// String message
rollbar.log('User action completed');

// Error object
rollbar.log(new Error('Something went wrong'));

// Message with additional data
rollbar.log('User action', { userId: 123, action: 'login' });

// Message with callback
rollbar.log('Processing data', (err, data) => {
  if (err) console.error('Failed to log:', err);
});

// Multiple arguments
rollbar.log('Payment processed', paymentData, user, callback);

Debug Method

Debug level logging for detailed diagnostic information.

/**
 * Log a message or error at the 'debug' level
 * @param args - Variable arguments: message, error, object, callback, etc.
 * @returns Object containing the UUID of the logged item
 */
function debug(...args: LogArgument[]): LogResult;

Info Method

Informational logging for general application events.

/**
 * Log a message or error at the 'info' level
 * @param args - Variable arguments: message, error, object, callback, etc.
 * @returns Object containing the UUID of the logged item
 */
function info(...args: LogArgument[]): LogResult;

Warn Method

Warning level logging for potential issues that don't stop execution.

/**
 * Log a message or error at the 'warning' level
 * @param args - Variable arguments: message, error, object, callback, etc.
 * @returns Object containing the UUID of the logged item
 */
function warn(...args: LogArgument[]): LogResult;

Warning Method

Alias for the warn method.

/**
 * Log a message or error at the 'warning' level (alias for warn)
 * @param args - Variable arguments: message, error, object, callback, etc.
 * @returns Object containing the UUID of the logged item
 */
function warning(...args: LogArgument[]): LogResult;

Error Method

Error level logging for exceptions and failures.

/**
 * Log a message or error at the 'error' level
 * @param args - Variable arguments: message, error, object, callback, etc.
 * @returns Object containing the UUID of the logged item
 */
function error(...args: LogArgument[]): LogResult;

Usage Examples:

// Log caught exception
try {
  riskyOperation();
} catch (err) {
  rollbar.error(err);
}

// Log error with context
rollbar.error('Database connection failed', {
  host: 'db.example.com',
  port: 5432,
  retries: 3
});

Critical Method

Critical level logging for severe errors requiring immediate attention.

/**
 * Log a message or error at the 'critical' level
 * @param args - Variable arguments: message, error, object, callback, etc.
 * @returns Object containing the UUID of the logged item
 */
function critical(...args: LogArgument[]): LogResult;

Wait Method

Wait for all pending items to be sent before executing callback.

/**
 * Wait for all pending items to be sent to Rollbar
 * @param callback - Function to call when all items are sent
 */
function wait(callback: () => void): void;

Usage Example:

// Ensure all logs are sent before shutting down
rollbar.error('Critical system error');
rollbar.wait(() => {
  console.log('All logs sent, shutting down...');
  process.exit(1);
});

Last Error Method

Get the last error that occurred in Rollbar itself.

/**
 * Get the last error that occurred within Rollbar
 * @returns The last error or null if no errors
 */
function lastError(): MaybeError;

Build JSON Payload

Build a JSON payload from item data for manual sending.

/**
 * Build JSON payload from item data
 * @param item - Item data to convert to JSON
 * @returns JSON string representation of the item
 */
function buildJsonPayload(item: any): string;

Send JSON Payload

Send a pre-built JSON payload to Rollbar.

/**
 * Send a pre-built JSON payload to Rollbar
 * @param jsonPayload - JSON string to send
 */
function sendJsonPayload(jsonPayload: string): void;

Types

type LogArgument = string | Error | object | Dictionary | Callback | Date | any[] | undefined;

interface LogResult {
  uuid: string;
}

type MaybeError = Error | undefined | null;

type Level = 'debug' | 'info' | 'warning' | 'error' | 'critical';

interface Callback<TResponse = any> {
  (err: MaybeError, response: TResponse): void;
}

type Dictionary = { [key: string]: unknown };

Argument Patterns

The logging methods accept flexible argument patterns:

  1. Message only: rollbar.error('Something happened')
  2. Error only: rollbar.error(new Error('Failed'))
  3. Message + Error: rollbar.error('Operation failed', error)
  4. Message + Data: rollbar.error('Failed to process', { userId: 123 })
  5. Message + Data + Callback: rollbar.error('Failed', data, callback)
  6. Error + Data: rollbar.error(error, { context: 'payment' })
  7. Multiple mixed arguments: rollbar.error('Payment failed', error, userData, callback)

The library automatically determines the appropriate handling based on argument types.

Install with Tessl CLI

npx tessl i tessl/npm-rollbar

docs

browser-integration.md

configuration.md

core-logging.md

index.md

react-native-integration.md

server-integration.md

telemetry.md

tile.json