// Test file for EyJsLogger import { createLogger, DEBUG_KEYS, logger } from '../index' console.log('🎨 EyJsLogger Test\n') // Basic logging console.log('1️⃣ Basic logging:') logger.info('Info message') logger.warn('Warning message') logger.error('Error message') logger.trace('Trace message') // Logging with context console.log('\n2️⃣ Logging with context:') logger.info('User login', { userId: 'user123', ip: '192.168.1.1' }) logger.warn('High memory usage', { memoryUsage: '85%', threshold: '80%' }) logger.error('Database connection failed', { error: 'Connection timeout', retryCount: 3, }) // Specific log types console.log('\n3️⃣ Specific log types:') logger.userAction('login', 'user456', { amount: 99.99, currency: 'USD' }) logger.systemInfo('Cache cleared successfully', { cacheSize: '2.5MB', itemsRemoved: 150, }) logger.businessLogic('Order processing completed', { orderId: 'order-789', processingTime: '2.3s', }) logger.deprecatedFeature('old-api', 'new-api', { endpoint: '/api/v1/users' }) logger.performanceWarning('Slow database query', { query: 'SELECT * FROM users WHERE...', duration: '2.5s', }) logger.securityWarning('Multiple failed login attempts', { userId: 'user123', attempts: 5, }) logger.configurationWarning('Missing environment variable', { variable: 'DATABASE_URL', }) logger.validationError('Invalid email format', 'email', 'invalid-email', { rule: 'email-format', }) logger.databaseError( 'Query execution failed', 'SELECT * FROM users WHERE id = ?', { error: 'Table does not exist' }, ) logger.apiError('Rate limit exceeded', '/api/users', 429, { retryAfter: '60s' }) logger.authenticationError('Invalid credentials', 'user123', { attemptCount: 3, }) logger.systemError('Memory limit exceeded', 'cache-service', { memoryUsage: '512MB', limit: '256MB', }) logger.businessError('Insufficient funds', 'payment-processing', { userId: 'user456', amount: 150.0, balance: 100.0, }) // Debug logging console.log('\n4️⃣ Debug logging:') logger.debug(DEBUG_KEYS.DATABASE, 'Executing query', { query: 'SELECT * FROM users WHERE active = ?', params: [true], }) logger.debug(DEBUG_KEYS.API, 'Request received', { method: 'GET', url: '/api/users', }) logger.debug(DEBUG_KEYS.AUTH, 'Token validation', { token: 'jwt-token-here', userId: 'user123', }) logger.debug(DEBUG_KEYS.CACHE, 'Cache miss', { key: 'user:123', ttl: '3600s' }) logger.debug(DEBUG_KEYS.VALIDATION, 'Field validation', { field: 'email', value: 'test@example.com', }) logger.debug(DEBUG_KEYS.PERFORMANCE, 'Performance metric', { operation: 'database_query', duration: '120ms', }) // Different themes console.log('\n5️⃣ Different themes:') console.log('\n🌙 Dark theme:') const darkLogger = createLogger({ level: 'debug', enableDebug: true, debugKeys: ['eyjslogger:database', 'eyjslogger:api'], colors: { theme: 'dark' }, }) darkLogger.info('Dark theme info message') darkLogger.warn('Dark theme warning message') darkLogger.error('Dark theme error message') console.log('\n🌈 Rainbow theme:') const rainbowLogger = createLogger({ level: 'debug', enableDebug: true, debugKeys: ['eyjslogger:database', 'eyjslogger:api'], colors: { theme: 'rainbow' }, }) rainbowLogger.info('Rainbow theme info message') rainbowLogger.warn('Rainbow theme warning message') rainbowLogger.error('Rainbow theme error message') console.log('\n⚪ Minimal theme:') const minimalLogger = createLogger({ level: 'debug', enableDebug: true, debugKeys: ['eyjslogger:database', 'eyjslogger:api'], colors: { theme: 'minimal' }, }) minimalLogger.info('Minimal theme info message') minimalLogger.warn('Minimal theme warning message') minimalLogger.error('Minimal theme error message') // Custom colors console.log('\n6️⃣ Custom colors:') const customLogger = createLogger({ level: 'debug', enableDebug: true, debugKeys: ['my-app:custom'], colors: { levels: { info: '\x1b[94m', // bright blue warn: '\x1b[95m', // bright magenta error: '\x1b[91m', // bright red }, debugKeys: { 'my-app:custom': '\x1b[96m', // bright cyan }, logTypes: { userAction: '\x1b[93m', // bright yellow }, }, }) customLogger.info('Custom blue info message') customLogger.warn('Custom magenta warning message') customLogger.error('Custom red error message') customLogger.userAction('Custom yellow user action', 'user123') customLogger.debug('my-app:custom', 'Custom cyan debug message') // Dynamic color changes console.log('\n7️⃣ Dynamic color changes:') logger.info('Original info message') logger.setColorTheme('rainbow') logger.info('Rainbow info message') logger.addCustomColors({ levels: { info: '\x1b[96m' } }) logger.info('Custom cyan info message') logger.disableColors() logger.info('No color info message') logger.enableColors() logger.info('Color info message restored') console.log('\n✅ Test completed!') console.log('🎉 EyJsLogger is working perfectly!') console.log('💡 To use colors: FORCE_COLOR=1 npx tsx test.ts')