import logger from './src/lib/logger.js'; // Test the logging system async function testLogging() { console.log('๐Ÿงช Testing logging system...'); try { // Set a test user logger.setUser('test-user'); // Test different log levels await logger.info('Application started', 'JEI Stock App has been started successfully'); await logger.warn('Low stock warning', 'Product ABC has low stock levels', { product: 'ABC', currentStock: 5 }); await logger.error('Database connection failed', 'Failed to connect to external API', { endpoint: 'https://api.example.com', statusCode: 500 }); await logger.debug('User interaction', 'User clicked on stock item', { itemId: 'stock-123', timestamp: new Date().toISOString() }); // Test convenience methods await logger.logStockOperation('added', 'Test Product', 100, 'admin'); await logger.logCustomerOperation('created', 'Test Company', 'admin'); await logger.logBookOutOperation('Test Company', [ { name: 'Test Product', quantity: 10 } ], 'admin'); console.log('โœ… Successfully created test logs!'); // Retrieve and display logs const logs = await logger.getLogs({ limit: 10 }); console.log('๐Ÿ“‹ Recent logs:'); console.log(logs.items.map(log => `${log.level.toUpperCase()}: ${log.action} - ${log.details || 'No details'}`)); } catch (error) { console.error('โŒ Error testing logging:', error); } } // Run the test testLogging();