color-logger-cli
v1.0.2
Published
CLI logger with colored output and log levels
Readme
color-logger-cli
CLI logger with colored output and log levels
Install
npm install -g color-logger-cli
Usage as CLI
clog info "Server started" clog success "Deployment complete" clog warn "Low disk space" clog error "Connection failed" clog debug "Variable value: 42" clog fatal "System crashed"
CLI Options
--timestamp Add timestamp to output --level Set minimum log level --logfile Write logs to file --quiet Suppress console output
CLI Examples
clog --timestamp info "Server running" clog --level debug info "Shows debug level too" clog --logfile app.log error "Logged to file"
Usage as Module
Simple log function
const clog = require('color-logger-cli');
clog.log('info', 'Server started'); clog.log('error', 'Failed to connect'); clog.log('success', 'File saved'); clog.log('debug', 'User data', { timestamp: true });
Logger instance
const { Logger } = require('color-logger-cli');
const logger = new Logger({ level: 'debug', timestamp: true }); logger.info('App started'); logger.error('Something broke'); logger.warn('Disk space low'); logger.success('Task complete'); logger.debug('Debug info'); logger.fatal('System crash');
Shorthand methods
const logger = new Logger(); logger.info('Hello'); logger.error('Oops'); logger.success('Done');
With config file
Create .loggerrc in your project root:
{ "level": "debug", "timestamp": true, "logFile": "logs/app.log" }
Then:
const { Logger } = require('color-logger-cli'); const logger = new Logger(); // Auto-loads config logger.info('Will have timestamp and save to file');
License
MIT
Author
Exogamy
