console_tools 2.0.1
console_tools: ^2.0.1 copied to clipboard
A console logger class, with custom colors and text styles already defined.
A lightweight Dart console logger with ANSI color support, log-level icons, timestamps, and JSON pretty-printing.
Features #
- Five log levels:
debug,info,success,warning,error - ANSI color-coded output (grey, cyan, green, yellow, red)
- Icons for each level: đ âšī¸ â â ī¸ â
- Optional tag to identify the source of a log entry
- Timestamp prefix (
[HH:mm:ss]) - JSON pretty-printing with indentation
- Global toggles:
Console.enableColorsandConsole.showTimestamp
Installation #
Add the package to your pubspec.yaml:
dependencies:
console_tools: ^2.0.0
Then run:
dart pub get
Usage #
import 'package:console_tools/console_tools.dart';
void main() {
Console.d("Debug message");
Console.i("Info message", tag: "AUTH");
Console.s("Login successful");
Console.w("API slow response");
Console.e("Crash detected");
Console.json({
"user": "Younes",
"role": "developer",
});
}
Sample output #
[12:34:56] đ Debug message
[12:34:56] âšī¸ [AUTH] Info message
[12:34:56] â
Login successful
[12:34:56] â ī¸ API slow response
[12:34:56] â Crash detected
[12:34:56] đ {
"user": "Younes",
"role": "developer"
}
API Reference #
Console class #
| Method | Level | Color | Description |
|---|---|---|---|
Console.d(msg, {tag}) |
debug | grey | Debug information |
Console.i(msg, {tag}) |
info | cyan | General information |
Console.s(msg, {tag}) |
success | green | Success confirmation |
Console.w(msg, {tag}) |
warning | yellow | Non-critical warnings |
Console.e(msg, {tag}) |
error | red | Errors and exceptions |
Console.json(obj, {tag}) |
debug | grey | Pretty-prints a JSON object |
Console.log(msg, {name}) |
info | cyan | Alias for Console.i |
Global settings #
Console.enableColors = false; // disable ANSI colors (default: true)
Console.showTimestamp = false; // hide the [HH:mm:ss] prefix (default: true)
License #
MIT
đ More Packages #
đ¨âđģ Developer Card #
Younes M'rabti #
đ§ Email: admin@youmti.net
đ Website: youmti.net
đŧ LinkedIn: younesmrabti1996