console_tools logo

pub package pub likes pub points platform

GitHub stars GitHub issues GitHub license GitHub last commit

Build status

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.enableColors and Console.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 avatar

Younes M'rabti

📧 Email: admin@youmti.net
🌐 Website: youmti.net
đŸ’ŧ LinkedIn: younesmrabti1996

Libraries

console_tools
A lightweight, colorized console logger for Dart and Flutter applications.