/

Console Output Configuration

Console output allows you to see log messages directly in your terminal or browser console. Enable or disable console logging based on your environment needs.

Basic Console Configuration

Enable or disable console output using the consoleEnabled option:

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

Log.configure({
    consoleEnabled: true,    // Enable console output
    minimumLevel: 'info'
});

Log.info('This will appear in console');

Environment-Based Console Settings

Development Environment

Log.configure({
    consoleEnabled: true,
    minimumLevel: 'debug'
});

Production Environment

Log.configure({
    consoleEnabled: false,   // Disable console in production
    minimumLevel: 'warn',
    persist: true           // Use file logging instead
});

Conditional Console Logging

const isDevelopment = process.env.NODE_ENV === 'development';

Log.configure({
    consoleEnabled: isDevelopment,
    minimumLevel: isDevelopment ? 'debug' : 'warn'
});

Using Environment Variables

import dotenv from 'dotenv';
dotenv.config();

Log.configure({
    consoleEnabled: process.env.CONSOLE_LOGGING === 'true',
    minimumLevel: process.env.LOG_LEVEL || 'info'
});

Best Practices

Console Output Guidelines

  • Development: Enable console for immediate feedback
  • Production: Disable console to avoid performance impact and log noise
  • Testing: Disable console to keep test output clean
  • Browser: Console output is visible to users, use carefully
Previous
Log Levels