
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@bobandbob/colorlogs
Advanced tools
A simple and lightweight logging library that adds colorful output to console messages, making development debugging easier and more visually appealing.
A simple, lightweight TypeScript/Node.js module to add color and customizable formatting to your console logs.
npm install @asynico/coloredlogging
import { createLogger } from '@asynico/coloredlogging';
const logger = createLogger();
logger.info('This is an informational message.');
logger.success('This is a success message.');
logger.warn('This is a warning message.');
logger.error('This is an error message.');
Create a logger with custom colors:
import { createLogger } from '@asynico/coloredlogging';
const customTheme = {
info: '#0066CC',
success: '#00AA00',
warn: '#FF8800',
error: '#CC0000',
};
const logger = createLogger({ theme: customTheme });
logger.info('Custom colored info message');
logger.success('Custom colored success message');
Customize how your logs are formatted:
import { createLogger } from '@asynico/coloredlogging';
const customLogFormat = ({ level, message, color, timestamp }) => {
return `${color}🚀 [${level.padEnd(7)}] ${timestamp ? `${timestamp} - ` : ''}${message}\x1b[0m`;
};
const logger = createLogger({
logFormat: customLogFormat,
showTimestamp: true
});
logger.info('This message uses custom formatting');
Define your own log levels:
import { createLogger } from '@asynico/coloredlogging';
const theme = {
debug: '#888888',
info: '#0066CC',
success: '#00AA00',
warn: '#FF8800',
error: '#CC0000',
critical: '#FF0066'
};
const logger = createLogger({
theme,
levels: ['debug', 'info', 'success', 'warn', 'error', 'critical']
});
logger.debug('Debug information');
logger.critical('Critical system error');
import { createLogger } from '@asynico/coloredlogging';
const logger = createLogger({ showTimestamp: false });
logger.info('This message has no timestamp');
createLogger(options?: LoggerOptions)
Creates a new logger instance with the specified options.
theme?: LoggerTheme
- Color theme for different log levelslogFormat?: Function
- Custom formatting function for log outputshowTimestamp?: boolean
- Whether to include timestamps (default: true
)levels?: LogLevel[]
- Array of log levels to create methods for (default: ['info', 'success', 'warn', 'error']
){
info: '#0000FF',
success: '#008000',
warn: '#FFFF00',
error: '#FF0000'
}
LogLevel
type LogLevel = 'info' | 'success' | 'warn' | 'error';
LoggerTheme
interface LoggerTheme {
info: string;
success: string;
warn: string;
error: string;
[key: string]: string; // Allows custom log levels
}
LoggerOptions
interface LoggerOptions {
theme?: LoggerTheme;
logFormat?: (opts: {
level: LogLevel;
message: string;
color: string;
timestamp: string;
}) => string;
showTimestamp?: boolean;
levels?: LogLevel[];
}
toAnsi(color: string): string
Converts hex colors to ANSI escape codes for terminal output.
import { toAnsi } from '@asynico/coloredlogging';
console.log(`${toAnsi('#FF0000')}This text is red\x1b[0m`);
defaultTheme
The default color theme object.
import { defaultTheme } from '@asynico/coloredlogging';
console.log(defaultTheme);
Colors can be specified as hex values:
#FF0000
(red)#00FF00
(green)#0000FF
(blue)import { createLogger } from '@asynico/coloredlogging';
const logger = createLogger();
logger.info('Application started');
logger.success('Database connected');
logger.warn('Deprecated API used');
logger.error('Connection failed');
import { createLogger } from '@asynico/coloredlogging';
const advancedLogger = createLogger({
theme: {
trace: '#666666',
debug: '#888888',
info: '#0066CC',
success: '#00AA00',
warn: '#FF8800',
error: '#CC0000',
fatal: '#FF0066'
},
levels: ['trace', 'debug', 'info', 'success', 'warn', 'error', 'fatal'],
logFormat: ({ level, message, color, timestamp }) =>
`${color}[${timestamp}] ${level.toUpperCase().padEnd(7)} | ${message}\x1b[0m`,
showTimestamp: true
});
advancedLogger.trace('Entering function');
advancedLogger.debug('Variable state: active');
advancedLogger.info('Process completed');
advancedLogger.fatal('System shutdown required');
This package includes full TypeScript definitions and is written in TypeScript. You get complete type safety and IntelliSense support out of the box.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
FAQs
A simple and lightweight logging library that adds colorful output to console messages, making development debugging easier and more visually appealing.
The npm package @bobandbob/colorlogs receives a total of 0 weekly downloads. As such, @bobandbob/colorlogs popularity was classified as not popular.
We found that @bobandbob/colorlogs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.