Minimal lightweight logging for JavaScript, adding reliable log level methods to any available console.log methods
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
loglevel provides five core logging methods that offer reliable output across all JavaScript environments with proper fallbacks and preserved line numbers.
/**
* Output trace message with full stack trace
* This will include a full stack trace in supported environments
* @param {...any} msg - Any data to log to the console
*/
trace(...msg: any[]): void;Usage Examples:
import log from 'loglevel';
log.setLevel('trace');
log.trace('Entering function processData()');
log.trace('Processing item:', { id: 123, name: 'example' });
log.trace('Variable state:', { count: 42, active: true });/**
* Output debug message to console
* Maps to console.debug() if available, otherwise console.log()
* @param {...any} msg - Any data to log to the console
*/
debug(...msg: any[]): void;Usage Examples:
import log from 'loglevel';
log.setLevel('debug');
log.debug('Cache miss for key:', 'user_123');
log.debug('API response:', { status: 200, data: [...] });
log.debug('Performance metric:', { duration: 245, memory: '12MB' });/**
* Alias for the debug method
* Provides familiar console.log-style interface
* @param {...any} msg - Any data to log to the console
*/
log(...msg: any[]): void;Usage Examples:
import logger from 'loglevel';
logger.setLevel('debug');
logger.log('This is equivalent to debug()');
logger.log('User action:', 'clicked_button', { buttonId: 'submit' });/**
* Output informational message
* Maps to console.info() if available, otherwise console.log()
* @param {...any} msg - Any data to log to the console
*/
info(...msg: any[]): void;Usage Examples:
import log from 'loglevel';
log.setLevel('info');
log.info('Application started successfully');
log.info('User logged in:', { userId: 456, username: 'john_doe' });
log.info('Configuration loaded:', { theme: 'dark', locale: 'en-US' });/**
* Output warning message
* Maps to console.warn() if available, otherwise console.log()
* @param {...any} msg - Any data to log to the console
*/
warn(...msg: any[]): void;Usage Examples:
import log from 'loglevel';
log.setLevel('warn');
log.warn('Deprecated API usage detected');
log.warn('Low disk space:', { available: '100MB', threshold: '500MB' });
log.warn('Rate limit approaching:', { requests: 95, limit: 100 });/**
* Output error message
* Maps to console.error() if available, otherwise console.log()
* @param {...any} msg - Any data to log to the console
*/
error(...msg: any[]): void;Usage Examples:
import log from 'loglevel';
log.setLevel('error');
log.error('Database connection failed');
log.error('Validation error:', { field: 'email', message: 'Invalid format' });
log.error('Unhandled exception:', error.stack);loglevel automatically adapts to different environments:
// Graceful handling - never throws errors
log.info('This works everywhere');
// Preserves line numbers and stack traces
log.debug('Check browser dev tools for accurate source location');