logit-pro
Version:
A flexible logging package that supports level-based logging (debug, info, warn, error) and automatic log rotation (daily, weekly, monthly, yearly). Easily configure log levels and rotation to suit your needs.
19 lines (15 loc) • 662 B
JavaScript
// test.js
const logIt = require('./index');
// Configure custom settings with dynamic log file name
logIt.configure({
logDirectory: './mylogs', // Custom log directory
logLevel: 'error', // Log everything (debug and above)
rotateBy: 'daily', // Rotation type ('daily', 'weekly', 'monthly', 'yearly')
fileName: 'myapp.log', // Custom log file name
});
// Log some messages
logIt.info('This is an info message');
logIt.warn('This is a warning');
logIt.error('An error occurred');
logIt.debug('Debugging information');
// The logs will be saved to ./mylogs/myapp-2025-07-17 02-47-26.log (or rotated based on time)