/

Logger SDK Installation

Before you begin

You'll need:

  • A ByteHide account and project token
  • Node.js 16+ for server-side applications
  • Modern browser for client-side applications

Installation Options

Add the ByteHide Logger SDK to your project using one of these methods:

npm

npm install @bytehide/logger

yarn

yarn add @bytehide/logger

pnpm

pnpm add @bytehide/logger

CDN (Browser)

<script src="https://cdn.jsdelivr.net/npm/@bytehide/logger@latest/dist/index.min.js"></script>

Basic Integration Example

Node.js / ES Modules

import { Log } from '@bytehide/logger';

// Configure the logger
Log.configure({
    minimumLevel: 'info',
    consoleEnabled: true
});

// Set your project token
Log.setProjectToken('your-project-token');

// Start logging
Log.info('Application started successfully!');

CommonJS (Node.js)

const { Log } = require('@bytehide/logger');

// Configure the logger
Log.configure({
    minimumLevel: 'info',
    consoleEnabled: true
});

// Set your project token
Log.setProjectToken('your-project-token');

// Start logging
Log.info('Application started successfully!');

Browser

<!DOCTYPE html>
<html>
<head>
    <script src="https://cdn.jsdelivr.net/npm/@bytehide/logger@latest/dist/index.min.js"></script>
</head>
<body>
    <script>
        // Configure the logger
        ByteHideLogger.Log.configure({
            minimumLevel: 'info',
            consoleEnabled: true
        });
        
        // Set your project token
        ByteHideLogger.Log.setProjectToken('your-project-token');
        
        // Start logging
        ByteHideLogger.Log.info('Web application started successfully!');
    </script>
</body>
</html>

Verify Installation

After installing the SDK, you can verify it's working by logging a test message:

import { Log } from '@bytehide/logger';

// Configure the logger
Log.configure({
    minimumLevel: 'debug',
    consoleEnabled: true
});

Log.setProjectToken('your-project-token');

try {
    // Test logging
    Log.info('ByteHide Logger initialized successfully!');
    Log.debug('Debug message - visible with debug level');
    Log.warn('Warning message');
    Log.error('Error message for testing');
    
    console.log('Logger is working correctly!');
} catch (error) {
    console.error('Error initializing logger:', error.message);
}

Runtime Compatibility

ByteHide Logger is compatible with:

Server-side Environments

  • Node.js 16+: Full logging capabilities including file persistence
  • Deno: Modern TypeScript runtime
  • Bun: Fast JavaScript runtime

Browser Support

  • Chrome 88+: Full support for modern features
  • Firefox 78+: Complete compatibility
  • Safari 14+: Full support
  • Edge 88+: Complete functionality

Framework Compatibility

Environment-Specific Setup

Node.js Applications

import { Log } from '@bytehide/logger';

// Node.js specific configuration
Log.configure({
    minimumLevel: 'info',
    consoleEnabled: true,
    persist: true,                    // Enable file logging
    filePath: 'logs/app.log',
    rollingInterval: 'day'
});

Log.setProjectToken(process.env.BYTEHIDE_PROJECT_TOKEN);
Log.info('Node.js application started');

Browser Applications

import { Log } from '@bytehide/logger';

// Browser specific configuration
Log.configure({
    minimumLevel: 'warn',
    consoleEnabled: true
    // Note: File logging not available in browsers
});

Log.setProjectToken('your-project-token');
Log.info('Web application started');

TypeScript Support

ByteHide Logger includes TypeScript definitions:

import { Log, LogSettings } from '@bytehide/logger';

// Type-safe configuration
const config: Partial<LogSettings> = {
    minimumLevel: 'info',
    consoleEnabled: true,
    maskSensitiveData: ['password', 'token']
};

Log.configure(config);
Log.setProjectToken('your-project-token');

// Type-safe logging
Log.info('TypeScript application started', {
    metadata: { version: '1.0.0' },
    tags: ['startup', 'typescript']
});

Next Steps

Previous
Create a project