Lowcon (also known as lowkey-console) is a minimalist, highly customizable logging utility for Node.js that enhances your console output with styled, colorful messages. It features animated loading indicators, progress bars, customizable log prefixes, and supports various logging levels. All while leveraging external libraries like ora
and cli-progress
.
- 🎨 Customizable Colors: Define and personalize log colors using ANSI escape codes for better visual clarity.
⚠️ Built-in Log Types: Convenient methods for warnings, errors, debug, success, and info logs.- ⏳ Animated Loading Symbols: Add dynamic loading indicators with a range of symbols.
- 📊 Progress Bars: Create interactive progress bars to track tasks or download progress.
- 🖋 Customizable Prefixes: Effortlessly add and tweak prefix characters for each log type.
- 🎯 External Dependency Support: Integrated with
ora
for loading indicators andcli-progress
for progress bars.
Here’s a preview of Lowcon in action:
Install Lowcon via npm:
npm install lowkey-console
Here’s an example of how to use Lowcon in your Node.js project:
import lowcon from 'lowkey-console'
// Simulate warn, error, success, info and debug state.
lowcon.warn('This is a warning.', { useBrackets: false, keepColoring: false, prefixChar: '» ' });
lowcon.error('This is an error.', { useBrackets: false, keepColoring: false, prefixChar: '» ' });
lowcon.success('This is a success.', { useBrackets: false, keepColoring: false, prefixChar: '» ' });
lowcon.info('This is an info.', { useBrackets: false, keepColoring: false, prefixChar: '» ' });
lowcon.debug('This is a debug.', { useBrackets: false, keepColoring: false, prefixChar: '» ' });
- warn(message, options): Logs a warning message.
- error(message, options): Logs an error message.
- success(message, options): Logs a success message.
- info(message, options): Logs an informational message.
- debug(message, options): Logs a debug message.
Create dynamic loading indicators:
// Simulate a loading state.
const loadingSession = lowcon.loading('This is a loading message...',
{
useBrackets: false,
keepColoring: false,
prefixChar: '» ',
onSuccess: (data) => `This is a successfully loaded message with status : ${data.code}`,
})
setTimeout(() => loadingSession.success({ code: 204 }), 5000);
Track the progress of an ongoing task:
let progressValue = 0;
const progressSession = lowcon.progress('Downloading...', progressValue, {
useBrackets: false,
keepColoring: false,
barWidth: 10,
prefixChar: '» ',
onSuccess: (data) => `This is a successful progress message with status : ${data.code}`,
onFail: (data) => `This is an failed progress message with status : ${data.code}`
});
const timer = setInterval(function () {
progressValue++
progressSession.update(progressValue)
if (progressValue >= 100) {
clearInterval(timer);
progressSession.succeed({ code: 200 });
}
}, 100);
You can easily modify log colors, symbols, and other settings with setConfig()
:
import { setConfig, ansiColors } = require('lowkey-console');
setConfig({
symbols: {
warning: '⚠',
error: '✘',
success: '✔',
info: 'i',
debug: '✇',
loading: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
progress: {
loaded: '█',
unloaded: '▒'
}
},
colors: {
warning: ansiColors.yellow,
error: ansiColors.red,
success: ansiColors.green,
debug: ansiColors.magenta,
info: ansiColors.blue,
loading: ansiColors.cyan,
progress: ansiColors.whiteBright
}
});
- symbols: Customize the symbols for different log types (
warning
,error
,success
, etc.). - colors: Define the colors for logs, loading animations, and progress bars.
- useBrackets: Choose whether to wrap symbols with brackets (default:
true
). - prefixChar: Set custom prefix characters for logs.
- keepColoring: Retain colors throughout the entire message (default:
false
). - interval: Set the speed for the loading animation (default:
100ms
). - onSuccess / onFail: Set custom messages or callback functions to execute after loading or progress completion.
- warn(message, options): Logs a warning message.
- error(message, options): Logs an error message.
- success(message, options): Logs a success message.
- info(message, options): Logs an informational message.
- debug(message, options): Logs a debug message.
- loading(message, options): Starts an animated loading indicator.
- progress(message, percentage, options): Displays a progress bar.
We welcome contributions! If you have suggestions, bug reports, or feature requests, feel free to open an issue or submit a pull request.
To develop or modify Lowcon locally:
- Clone the repository:
git clone https://github.com/OptiFiire/lowcon.git
- Navigate to the project directory:
cd lowcon
- Install dependencies:
npm install
- Run your tests and start making contributions!