Skip to content

Commit 82dd918

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 04b9e3d commit 82dd918

13 files changed

Lines changed: 239 additions & 104 deletions

File tree

.fvmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"flutter": "3.41.2"
3+
}

.github/workflows/publish.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: publish_pub_dev
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+*" # Trigger on version tags
7+
workflow_dispatch: # Allows manual triggering
8+
9+
jobs:
10+
publish:
11+
permissions:
12+
id-token: write
13+
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
14+
# env:
15+
# PUB_DEV_TOKEN: zero

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ build/
88
# Omit committing pubspec.lock for library packages; see
99
# https://dart.dev/guides/libraries/private-files#pubspeclock.
1010
pubspec.lock
11+
12+
# FVM Version Cache
13+
.fvm/

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dart.flutterSdkPath": ".fvm/versions/3.41.2"
3+
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.0.0
2+
- Major update.
3+
- Use Dart developper logger.
4+
- Better documentation.
5+
- Beautify the code.
6+
- Update README.md and CHANGELOG.md.
7+
18
## 1.0.1
29

310
- Latest version.

README.md

Lines changed: 124 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,135 @@
1+
<div align="center">
12

2-
## Usage
3+
<div align="center">
4+
<img src="https://raw.githubusercontent.com/youmtinetflutterpacks/console_tools/refs/heads/main/assets/readme_banner.png" alt="console_tools logo"/>
5+
</div>
6+
7+
[![pub package](https://img.shields.io/pub/v/console_tools.svg)](https://pub.dev/packages/console_tools)
8+
[![pub likes](https://img.shields.io/pub/likes/console_tools.svg)](https://pub.dev/packages/console_tools/score)
9+
[![pub points](https://img.shields.io/pub/points/console_tools.svg?color=blue)](https://pub.dev/packages/console_tools/score)
10+
[![platform](https://img.shields.io/badge/platform-flutter-blue)](https://flutter.dev)
11+
12+
[![GitHub stars](https://img.shields.io/github/stars/youmtinetflutterpacks/console_tools.svg?style=flat&logo=github&colorB=&label=Stars)](https://github.com/youmtinetflutterpacks/console_tools/stargazers)
13+
[![GitHub issues](https://img.shields.io/github/issues/youmtinetflutterpacks/console_tools.svg?style=flat&logo=github&colorB=&label=Issues)](https://github.com/youmtinetflutterpacks/console_tools/issues)
14+
[![GitHub license](https://img.shields.io/github/license/youmtinetflutterpacks/console_tools.svg?style=flat&logo=github&colorB=&label=License)](https://github.com/youmtinetflutterpacks/console_tools/blob/main/LICENSE)
15+
[![GitHub last commit](https://img.shields.io/github/last-commit/youmtinetflutterpacks/console_tools.svg?style=flat&logo=github&colorB=&label=Last%20Commit)](https://github.com/youmtinetflutterpacks/console_tools/commits/main)
16+
17+
18+
[![Build status](https://github.com/youmtinetflutterpacks/console_tools/workflows/publish_pub_dev/badge.svg?style=flat&logo=github&colorB=&label=Build)](https://github.com/youmtinetflutterpacks/console_tools)
19+
</div>
20+
21+
A lightweight Dart console logger with ANSI color support, log-level icons, timestamps, and JSON pretty-printing.
22+
23+
---
24+
25+
## Features
26+
27+
- **Five log levels**: `debug`, `info`, `success`, `warning`, `error`
28+
- **ANSI color-coded output** (grey, cyan, green, yellow, red)
29+
- **Icons** for each level: 🐛 ℹ️ ✅ ⚠️ ❌
30+
- **Optional tag** to identify the source of a log entry
31+
- **Timestamp** prefix (`[HH:mm:ss]`)
32+
- **JSON pretty-printing** with indentation
33+
- Global toggles: `Console.enableColors` and `Console.showTimestamp`
34+
35+
---
36+
37+
## Installation
338

39+
Add the package to your `pubspec.yaml`:
40+
41+
```yaml
42+
dependencies:
43+
console_tools: ^2.0.0
44+
```
45+
46+
Then run:
47+
48+
```sh
49+
dart pub get
50+
```
51+
52+
---
53+
54+
## Usage
455

556
```dart
657
import 'package:console_tools/console_tools.dart';
758
859
void main() {
9-
for (var element in ConsoleColors.values) {
10-
Console.log(
11-
element.name,
12-
color: element,
13-
consoleStyle: ConsoleStyles.normal,
14-
);
15-
}
16-
Console.log('awesome: Console log normal 002', consoleStyle: ConsoleStyles.clineote);
17-
Console.log('awesome: Console log normal 003', consoleStyle: ConsoleStyles.clineote);
18-
Console.log('awesome: Console log normal 004', consoleStyle: ConsoleStyles.clineote);
19-
Console.log('awesome: Console log normal', consoleStyle: ConsoleStyles.bold);
20-
Console.log('awesome: Console log', consoleStyle: ConsoleStyles.bold);
21-
Console.log('awesome: Console log clineote', consoleStyle: ConsoleStyles.clineote);
22-
Console.log('awesome: Console log clineoteFast', consoleStyle: ConsoleStyles.clineoteFast);
23-
Console.log('awesome: Console log italic', consoleStyle: ConsoleStyles.italic);
24-
Console.log('awesome: Console log lineThrought', consoleStyle: ConsoleStyles.lineThrought);
25-
Console.log('awesome: Console log normal2', consoleStyle: ConsoleStyles.normal2);
26-
Console.log('awesome: Console log opacity', consoleStyle: ConsoleStyles.opacity);
27-
Console.log('awesome: Console log underline', consoleStyle: ConsoleStyles.underline);
60+
Console.d("Debug message");
61+
Console.i("Info message", tag: "AUTH");
62+
Console.s("Login successful");
63+
Console.w("API slow response");
64+
Console.e("Crash detected");
65+
66+
Console.json({
67+
"user": "Younes",
68+
"role": "developer",
69+
});
2870
}
71+
```
2972

73+
### Sample output
74+
75+
```
76+
[12:34:56] 🐛 Debug message
77+
[12:34:56] ℹ️ [AUTH] Info message
78+
[12:34:56] ✅ Login successful
79+
[12:34:56] ⚠️ API slow response
80+
[12:34:56] ❌ Crash detected
81+
[12:34:56] 🐛 {
82+
"user": "Younes",
83+
"role": "developer"
84+
}
85+
```
86+
87+
---
88+
89+
## API Reference
90+
91+
### `Console` class
92+
93+
| Method | Level | Color | Description |
94+
|---|---|---|---|
95+
| `Console.d(msg, {tag})` | debug | grey | Debug information |
96+
| `Console.i(msg, {tag})` | info | cyan | General information |
97+
| `Console.s(msg, {tag})` | success | green | Success confirmation |
98+
| `Console.w(msg, {tag})` | warning | yellow | Non-critical warnings |
99+
| `Console.e(msg, {tag})` | error | red | Errors and exceptions |
100+
| `Console.json(obj, {tag})` | debug | grey | Pretty-prints a JSON object |
101+
| `Console.log(msg, {name})` | info | cyan | Alias for `Console.i` |
102+
103+
### Global settings
104+
105+
```dart
106+
Console.enableColors = false; // disable ANSI colors (default: true)
107+
Console.showTimestamp = false; // hide the [HH:mm:ss] prefix (default: true)
30108
```
31109

110+
---
111+
112+
## License
113+
114+
MIT
115+
116+
## 🔗 More Packages
117+
118+
- [Power GeoJSON](https://pub.dev/packages/power_geojson)
119+
- [PopupMenu2](https://pub.dev/packages/popup_menu_2)
120+
- [Flutter Azimuth](https://pub.dev/packages/flutter_azimuth)
121+
- [Map Contextual Menu](https://pub.dev/packages/longpress_popup)
122+
123+
---
124+
125+
## 👨‍💻 Developer Card
126+
127+
<div align="center">
128+
<img src="https://avatars.githubusercontent.com/u/47449165?v=4" alt="Younes M'rabti avatar" width="120" height="120" style="border-radius: 50%;" />
129+
130+
### Younes M'rabti
131+
132+
📧 Email: [admin@youmti.net](mailto:admin@youmti.net)
133+
🌐 Website: [youmti.net](https://www.youmti.net/)
134+
💼 LinkedIn: [younesmrabti1996](https://www.linkedin.com/in/younesmrabti1996/)
135+
</div>

assets/console_tools.png

60.4 KB
Loading

assets/console_tools_logo.png

683 KB
Loading

assets/logo.png

206 KB
Loading

assets/readme_banner.png

120 KB
Loading

0 commit comments

Comments
 (0)