sleeklogs
v1.0.7
Published
A library for better looks and better logs.
Downloads
11
Maintainers
Readme
SleekLog
SleekLog is a Node.js logging library designed to enhance the way developers log information in their applications. This library provides customizable and color-coded log outputs, file logging capabilities, and support for custom log levels, making it versatile for both development and production environments.
Features
- Color-coded Log Output: Customize log colors for better visual distinction between log levels.
- Custom Log Levels: Define and use custom log levels that suit your application's needs.
- File Logging: Enable logging to a file for persistent log storage.
- Error Handling with Traceability: Log errors with stack traces for easier debugging.
- Bar Chart Logging: Draw ASCII bar charts in the console for visual representation of metrics like CPU and memory usage.
- Flexible Configuration: Configure logging preferences such as file logging paths and whether to enable or disable certain features.
Supported Colors
SleekLog supports the following colors for log customization:
Foreground Colors:
- Black:
\x1b[30m
- Red:
\x1b[31m
- Green:
\x1b[32m
- Yellow:
\x1b[33m
- Blue:
\x1b[34m
- Magenta:
\x1b[35m
- Cyan:
\x1b[36m
- White:
\x1b[37m
- Black:
Background Colors:
- Black:
\x1b[40m
- Red:
\x1b[41m
- Green:
\x1b[42m
- Yellow:
\x1b[43m
- Blue:
\x1b[44m
- Magenta:
\x1b[45m
- Cyan:
\x1b[46m
- White:
\x1b[47m
- Black:
Installation
Install SleekLog using npm:
npm install sleeklogs
Please do not use
@lmaoleonix/sleeklogs
It's the same but just use sleeklogs.
Usage
Here's how to get started with SleekLog:
const SleekLog = require('sleeklogs');
const logger = new SleekLog({
enableFileLogging: true,
levels: {
debug: { color: "\x1b[36m" } // Example of the custom log level
}
});
logger.log('info', 'This is an informational message.', '#E1E1E1'); // Example using hex color
logger.log('debug', 'This is a custom debug message.');
logger.logError('An error occurred', new Error('Something went wrong'));
// Example of drawing a bar chart for CPU and memory usage
const currentCpuUsage = 30;
const totalCpuCapacity = 100;
const usedMemory = 4;
const totalMemory = 16;
logger.drawBar('CPU Usage', currentCpuUsage, totalCpuCapacity, 40);
logger.drawBar('Memory Usage', usedMemory, totalMemory, 40);
// A nice spinner if you need it for loading something
logger.startSpinner(5000, 'Processing data...', logger.colors.fg.magenta);
setTimeout(() => {
console.log('Operation completed.');
}, 6000);
Reporting Issues
Please report any bugs or issues you find while using SleekLog on our GitHub Issues page.
License
This project is licensed under the MIT License - see the LICENSE file for details.