A structured, colorful logging utility designed for modern Node.js and Edge runtime environments, providing robust logging capabilities with zero dependencies and minimal overhead.
- 🚀 Edge Runtime compatible
- 🎨 Colorful console output
- 📦 Module-based logging
- 👤 User context support
- 🔍 Multiple log levels (debug, info, warn, error)
- ⚙️ Configurable via environment variables
- 🎯 TypeScript support
- 🪶 Zero dependencies
- 🔒 Safe for sensitive environments
- 🌐 Works in all Node.js environments
npm install @bytware/logger
# or
yarn add @bytware/logger
# or
pnpm add @bytware/loggerimport logger from '@bytware/logger';
// Basic usage
logger.info('Application started');
logger.debug('Debug information', { someData: 123 });
logger.warn('Warning message');
logger.error('Error occurred', { error: new Error('Something went wrong') });
// Module-based logging
const authLogger = logger.child({ module: 'auth' });
authLogger.info('User logged in', { userId: '123' });
// Set user context
logger.setUserId('user-123')
.info('Action performed by user');
// Clear user context
logger.setUserId(null);Set the log level using the LOG_LEVEL environment variable:
LOG_LEVEL=debug # Show all logs
LOG_LEVEL=info # Show info and above (default)
LOG_LEVEL=warn # Show only warnings and errors
LOG_LEVEL=error # Show only errorsdebug: Detailed information for debugginginfo: General operational eventswarn: Warning conditionserror: Error conditions that should be investigated
[DD/MM HH:MM:SS.mmm] LEVEL [module] [userId] message data
For applications that need to ensure all logs are processed server-side (even when initiated from the client), see our Server-Side Logging Guide.
MIT