chromalogger 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHROMA.md +253 -0
- package/INFO.md +128 -0
- package/README.fr.md +360 -0
- package/README.md +66 -254
- package/core/formatters/objectFormatter.js +42 -11
- package/core/loggers/consoleLogger.js +88 -23
- package/core/utils/validate.js +6 -3
- package/index.js +17 -57
- package/package.json +4 -1
- package/test.js +34 -5
package/README.fr.md
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
# ChromaLogger
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/chromalogger)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://github.com/OrssiMp/chromalogger/stargazers)
|
|
6
|
+
|
|
7
|
+
[🇬🇧 English](README.md) | [🇫🇷 Français](README.fr.md)
|
|
8
|
+
|
|
9
|
+
ChromaLogger est une bibliothèque Node.js puissante et flexible pour la journalisation de console avec un support avancé des couleurs, des styles et des fonctionnalités de débogage. Parfaite pour le développement et le débogage d'applications Node.js.
|
|
10
|
+
|
|
11
|
+
## 🚀 Fonctionnalités
|
|
12
|
+
|
|
13
|
+
- 🌈 Support avancé des couleurs et styles (16+ couleurs, formatage de texte)
|
|
14
|
+
- 📊 Niveaux de log intégrés (DEBUG, INFO, WARN, ERROR)
|
|
15
|
+
- 🔄 Détection des références circulaires
|
|
16
|
+
- 📝 Support des templates avec placeholders
|
|
17
|
+
- 🛠️ Création de loggers personnalisés
|
|
18
|
+
- 💻 Utilisation en ligne de commande avec `clog`
|
|
19
|
+
- 🔌 Architecture extensible et API simple
|
|
20
|
+
|
|
21
|
+
## 📦 Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Avec npm
|
|
25
|
+
npm install chromalogger
|
|
26
|
+
|
|
27
|
+
# Ou avec Yarn
|
|
28
|
+
yarn add chromalogger
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 💡 Démarrage Rapide
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import { log, info, warn, error, createLogger } from 'chromalogger';
|
|
35
|
+
|
|
36
|
+
// Utilisation de base
|
|
37
|
+
log('Ceci est un message de log');
|
|
38
|
+
info('Message informatif');
|
|
39
|
+
warn('Message d\'avertissement');
|
|
40
|
+
error('Message d\'erreur');
|
|
41
|
+
|
|
42
|
+
// Avec styles
|
|
43
|
+
const success = createLogger('green', 'bold');
|
|
44
|
+
success('Opération réussie !');
|
|
45
|
+
|
|
46
|
+
// Templates avec placeholders
|
|
47
|
+
const utilisateur = { nom: 'Alice', age: 30 };
|
|
48
|
+
info('L\'utilisateur {0} a {1} ans', utilisateur.nom, utilisateur.age);
|
|
49
|
+
|
|
50
|
+
// Styles en ligne
|
|
51
|
+
import { red, bgYellow, bold } from 'chromalogger';
|
|
52
|
+
console.log(red('Texte en rouge') + ' et ' + bgYellow('fond jaune'));
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 📚 Documentation
|
|
56
|
+
|
|
57
|
+
### Niveaux de Log
|
|
58
|
+
|
|
59
|
+
ChromaLogger définit 5 niveaux de log, du plus bas au plus élevé :
|
|
60
|
+
|
|
61
|
+
| Niveau | Valeur | Description |
|
|
62
|
+
| ------- | ------ | -------------------------------------------------------- |
|
|
63
|
+
| `DEBUG` | 0 | Messages détaillés pour le débogage |
|
|
64
|
+
| `INFO` | 1 | Informations générales sur le déroulement du programme |
|
|
65
|
+
| `WARN` | 2 | Situations potentiellement problématiques |
|
|
66
|
+
| `ERROR` | 3 | Erreurs qui n'empêchent pas l'application de fonctionner |
|
|
67
|
+
| `NONE` | 4 | Aucun log ne sera affiché |
|
|
68
|
+
|
|
69
|
+
### Fonctions Principales
|
|
70
|
+
|
|
71
|
+
#### `createLogger(...styles)`
|
|
72
|
+
|
|
73
|
+
Crée un nouveau logger personnalisé avec les styles spécifiés.
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
const header = createLogger('bgBlue', 'white', 'bold');
|
|
77
|
+
header('En-tête important');
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### `setLogLevel(level)`
|
|
81
|
+
|
|
82
|
+
Définit le niveau de log minimum à afficher.
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
setLogLevel('DEBUG'); // Affiche tout
|
|
86
|
+
setLogLevel('WARN'); // Affiche uniquement WARN et ERROR
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Styles Disponibles
|
|
90
|
+
|
|
91
|
+
#### Couleurs de texte
|
|
92
|
+
- `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
|
|
93
|
+
|
|
94
|
+
#### Arrière-plans
|
|
95
|
+
- `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`
|
|
96
|
+
|
|
97
|
+
#### Styles de texte
|
|
98
|
+
- `bright` - Texte en gras
|
|
99
|
+
- `dim` - Texte atténué
|
|
100
|
+
- `italic` - Texte en italique
|
|
101
|
+
- `underline` - Texte souligné
|
|
102
|
+
- `blink` - Texte clignotant
|
|
103
|
+
- `reverse` - Inverse les couleurs
|
|
104
|
+
- `hidden` - Texte caché
|
|
105
|
+
- `strikethrough` - Texte barré
|
|
106
|
+
|
|
107
|
+
## 🤝 Contribution
|
|
108
|
+
|
|
109
|
+
Les contributions sont les bienvenues ! Pour contribuer :
|
|
110
|
+
|
|
111
|
+
1. Forkez le dépôt
|
|
112
|
+
2. Créez une branche pour votre fonctionnalité (`git checkout -b feature/ma-fonctionnalite`)
|
|
113
|
+
3. Committez vos changements (`git commit -am 'Ajouter une fonctionnalité'`)
|
|
114
|
+
4. Poussez vers la branche (`git push origin feature/ma-fonctionnalite`)
|
|
115
|
+
5. Ouvrez une Pull Request
|
|
116
|
+
|
|
117
|
+
## 📄 Licence
|
|
118
|
+
|
|
119
|
+
Ce projet est sous licence MIT - voir le fichier [LICENCE](LICENSE) pour plus de détails.
|
|
120
|
+
|
|
121
|
+
## 🙏 Remerciements
|
|
122
|
+
|
|
123
|
+
- Inspiré par des bibliothèques populaires comme chalk, winston et debug
|
|
124
|
+
- Merci à tous les contributeurs qui ont aidé à améliorer ce projet
|
|
125
|
+
# Afficher l'aide
|
|
126
|
+
## 🛠️ Interface en Ligne de Commande (CLI)
|
|
127
|
+
|
|
128
|
+
ChromaLogger inclut un utilitaire en ligne de commande `clog` :
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Afficher l'aide
|
|
132
|
+
npx clog --help
|
|
133
|
+
|
|
134
|
+
# Afficher un message simple
|
|
135
|
+
npx clog "Mon message"
|
|
136
|
+
|
|
137
|
+
# Utiliser des couleurs et styles
|
|
138
|
+
npx clog --color red --style bright "Message important"
|
|
139
|
+
|
|
140
|
+
## 🔍 Exemples Complets
|
|
141
|
+
|
|
142
|
+
### Configuration d'un logger personnalisé
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
import { createLogger, setLogLevel } from 'chromalogger';
|
|
146
|
+
|
|
147
|
+
// Créer des loggers personnalisés
|
|
148
|
+
const success = createLogger('green', 'bright');
|
|
149
|
+
const error = createLogger('red', 'bold');
|
|
150
|
+
const debug = createLogger('blue', 'dim');
|
|
151
|
+
|
|
152
|
+
// Définir le niveau de log
|
|
153
|
+
setLogLevel('DEBUG');
|
|
154
|
+
|
|
155
|
+
// Utilisation
|
|
156
|
+
success('Connexion réussie !');
|
|
157
|
+
error('Échec de la connexion');
|
|
158
|
+
debug('État de la connexion:', { status: 'connected', time: Date.now() });
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Journalisation dans une application Express
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
import express from 'express';
|
|
165
|
+
import { createLogger } from 'chromalogger';
|
|
166
|
+
|
|
167
|
+
const app = express();
|
|
168
|
+
const logger = createLogger('magenta');
|
|
169
|
+
const errorLogger = createLogger('red', 'bold');
|
|
170
|
+
|
|
171
|
+
app.use((req, res, next) => {
|
|
172
|
+
logger(`${req.method} ${req.url}`);
|
|
173
|
+
next();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
app.get('/', (req, res) => {
|
|
177
|
+
res.send('Bienvenue sur mon API');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Gestion des erreurs
|
|
181
|
+
app.use((err, req, res, next) => {
|
|
182
|
+
errorLogger('ERREUR:', err.message);
|
|
183
|
+
res.status(500).send('Quelque chose a mal tourné !');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
app.listen(3000, () => {
|
|
187
|
+
logger('Serveur démarré sur http://localhost:3000');
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 📝 Bonnes Pratiques
|
|
192
|
+
|
|
193
|
+
1. **Environnement de développement** : Utilisez `DEBUG` pour avoir un maximum d'informations
|
|
194
|
+
2. **Environnement de production** : Utilisez `WARN` ou `ERROR` pour éviter la surcharge de logs
|
|
195
|
+
3. **Créer des loggers spécifiques** : Utilisez `createLogger()` pour des catégories de logs différentes
|
|
196
|
+
4. **Éviter les logs sensibles** : Ne loguez jamais de mots de passe ou informations sensibles
|
|
197
|
+
5. **Utiliser les bons niveaux** :
|
|
198
|
+
- `debug` pour le débogage détaillé
|
|
199
|
+
- `info` pour les informations importantes
|
|
200
|
+
- `warn` pour les avertissements
|
|
201
|
+
- `error` pour les erreurs
|
|
202
|
+
|
|
203
|
+
## 📄 Licence
|
|
204
|
+
|
|
205
|
+
MIT © [Votre Nom]
|
|
206
|
+
|
|
207
|
+
Pour plus d'informations sur les fonctionnalités avancées, consultez la [documentation complète](https://github.com/OrssiMp/chromalogger#readme).
|
|
208
|
+
|
|
209
|
+
## 🤝 Contribuer
|
|
210
|
+
|
|
211
|
+
Les contributions sont les bienvenues ! Voici comment contribuer :
|
|
212
|
+
|
|
213
|
+
1. Forkez le projet
|
|
214
|
+
2. Créez une branche pour votre fonctionnalité (`git checkout -b feature/AmazingFeature`)
|
|
215
|
+
3. Committez vos changements (`git commit -m 'Add some AmazingFeature'`)
|
|
216
|
+
4. Poussez vers la branche (`git push origin feature/AmazingFeature`)
|
|
217
|
+
5. Ouvrez une Pull Request
|
|
218
|
+
|
|
219
|
+
## 📄 Licence
|
|
220
|
+
|
|
221
|
+
Distribué sous licence MIT. Voir le fichier `LICENSE` pour plus d'informations.
|
|
222
|
+
|
|
223
|
+
## 📞 Contact
|
|
224
|
+
|
|
225
|
+
Orssi Mp - [@OrssiMp](https://github.com/OrssiMp) - orssimpiere5@gmail.com
|
|
226
|
+
|
|
227
|
+
Lien du projet : [https://github.com/OrssiMp/chromalogger](https://github.com/OrssiMp/chromalogger)
|
|
228
|
+
|
|
229
|
+
// Couleurs de base
|
|
230
|
+
logger.red('Ceci est en rouge');
|
|
231
|
+
logger.green('Ceci est en vert');
|
|
232
|
+
logger.blue('Ceci est en bleu');
|
|
233
|
+
logger.yellow('Ceci est en jaune');
|
|
234
|
+
|
|
235
|
+
````
|
|
236
|
+
|
|
237
|
+
### Avec CommonJS
|
|
238
|
+
|
|
239
|
+
```javascript
|
|
240
|
+
const logger = require('logcolor-js');
|
|
241
|
+
|
|
242
|
+
// Arrière-plans colorés
|
|
243
|
+
logger.bgRed(' Fond rouge ');
|
|
244
|
+
logger.bgGreen(' Fond vert ');
|
|
245
|
+
logger.bgBlue(' Fond bleu ');
|
|
246
|
+
````
|
|
247
|
+
|
|
248
|
+
## Fonctionnalités
|
|
249
|
+
|
|
250
|
+
### Couleurs de texte
|
|
251
|
+
|
|
252
|
+
- `red(text)` - Texte rouge
|
|
253
|
+
- `green(text)` - Texte vert
|
|
254
|
+
- `blue(text)` - Texte bleu
|
|
255
|
+
- `yellow(text)` - Texte jaune
|
|
256
|
+
- `white(text)` - Texte blanc
|
|
257
|
+
- `black(text)` - Texte noir
|
|
258
|
+
- `magenta(text)` - Texte magenta
|
|
259
|
+
- `cyan(text)` - Texte cyan
|
|
260
|
+
|
|
261
|
+
### Arrière-plans
|
|
262
|
+
|
|
263
|
+
- `bgRed(text)` - Fond rouge
|
|
264
|
+
- `bgGreen(text)` - Fond vert
|
|
265
|
+
- `bgBlue(text)` - Fond bleu
|
|
266
|
+
- `bgYellow(text)` - Fond jaune
|
|
267
|
+
- `bgWhite(text)` - Fond blanc
|
|
268
|
+
- `bgBlack(text)` - Fond noir
|
|
269
|
+
- `bgMagenta(text)` - Fond magenta
|
|
270
|
+
- `bgCyan(text)` - Fond cyan
|
|
271
|
+
|
|
272
|
+
### Styles de texte
|
|
273
|
+
|
|
274
|
+
- `bold(text)` - Texte en gras
|
|
275
|
+
- `underline(text)` - Texte souligné
|
|
276
|
+
- `italic(text)` - Texte en italique
|
|
277
|
+
- `inverse(text)` - Inverse les couleurs
|
|
278
|
+
- `strikethrough(text)` - Texte barré
|
|
279
|
+
|
|
280
|
+
### Niveaux de log
|
|
281
|
+
|
|
282
|
+
- `setLogLevel(level)` - Définit le niveau de log ('DEBUG', 'INFO', 'WARN', 'ERROR')
|
|
283
|
+
- `debug(...args)` - Message de débogage
|
|
284
|
+
- `info(...args)` - Information
|
|
285
|
+
- `warn(...args)` - Avertissement
|
|
286
|
+
- `error(...args)` - Erreur
|
|
287
|
+
- `success(...args)` - Succès (alias pour info avec icône de succès)
|
|
288
|
+
- `warning(...args)` - Avertissement (alias pour warn avec icône d'avertissement)
|
|
289
|
+
|
|
290
|
+
## Exemples avancés
|
|
291
|
+
|
|
292
|
+
### Combinaison de styles
|
|
293
|
+
|
|
294
|
+
```javascript
|
|
295
|
+
// Combinaison de styles
|
|
296
|
+
logger.bold(logger.red('Texte en gras et rouge'));
|
|
297
|
+
logger.bgBlue(logger.white('Texte blanc sur fond bleu'));
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Niveaux de log
|
|
301
|
+
|
|
302
|
+
```javascript
|
|
303
|
+
// Définir le niveau de log (par défaut: 'INFO')
|
|
304
|
+
logger.setLogLevel('DEBUG');
|
|
305
|
+
|
|
306
|
+
// Messages de log
|
|
307
|
+
logger.debug('Message de débogage');
|
|
308
|
+
logger.info('Information');
|
|
309
|
+
logger.warn('Avertissement');
|
|
310
|
+
logger.error('Erreur');
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Avec des objets et tableaux
|
|
314
|
+
|
|
315
|
+
```javascript
|
|
316
|
+
// Objets
|
|
317
|
+
const user = {
|
|
318
|
+
name: 'John',
|
|
319
|
+
age: 30,
|
|
320
|
+
roles: ['admin', 'user'],
|
|
321
|
+
};
|
|
322
|
+
logger.info('Utilisateur:', user);
|
|
323
|
+
|
|
324
|
+
// Tableaux
|
|
325
|
+
const numbers = [1, 2, 3, 4, 5];
|
|
326
|
+
logger.info('Nombres:', numbers);
|
|
327
|
+
|
|
328
|
+
// Références circulaires
|
|
329
|
+
const obj1 = { name: 'Objet 1' };
|
|
330
|
+
const obj2 = { name: 'Objet 2', ref: obj1 };
|
|
331
|
+
obj1.ref = obj2;
|
|
332
|
+
logger.info('Objet avec référence circulaire:', obj1);
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Personnalisation
|
|
336
|
+
|
|
337
|
+
### Styles personnalisés
|
|
338
|
+
|
|
339
|
+
```javascript
|
|
340
|
+
// Accès direct aux codes ANSI
|
|
341
|
+
console.log(
|
|
342
|
+
`${logger.styles.bold}${logger.styles.red}Texte en gras et rouge${logger.styles.reset}`
|
|
343
|
+
);
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Templates
|
|
347
|
+
|
|
348
|
+
```javascript
|
|
349
|
+
const name = 'Alice';
|
|
350
|
+
const age = 30;
|
|
351
|
+
logger.info('Nom: {0}, Âge: {1}', name, age);
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## Contribution
|
|
355
|
+
|
|
356
|
+
Les contributions sont les bienvenues ! N'hésitez pas à ouvrir une issue ou une pull request.
|
|
357
|
+
|
|
358
|
+
## Licence
|
|
359
|
+
|
|
360
|
+
MIT
|
package/README.md
CHANGED
|
@@ -1,254 +1,66 @@
|
|
|
1
|
-
# ChromaLogger
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/chromalogger)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://github.com/OrssiMp/chromalogger/stargazers)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
customLogger('Message personnalisé');
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Avec CommonJS
|
|
71
|
-
|
|
72
|
-
```javascript
|
|
73
|
-
const { log, info, warn, error } = require('chromalogger');
|
|
74
|
-
|
|
75
|
-
// Utilisation des loggers
|
|
76
|
-
log('Message standard');
|
|
77
|
-
info('Information');
|
|
78
|
-
warn('Avertissement');
|
|
79
|
-
error('Erreur');
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## 🛠️ Interface en Ligne de Commande (CLI)
|
|
83
|
-
|
|
84
|
-
ChromaLogger inclut un utilitaire en ligne de commande `clog` :
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# Afficher l'aide
|
|
88
|
-
npx clog --help ou clog --help
|
|
89
|
-
|
|
90
|
-
# Afficher un message simple
|
|
91
|
-
npx clog "Mon message" ou clog "Mon message"
|
|
92
|
-
|
|
93
|
-
# Utiliser des couleurs et styles
|
|
94
|
-
npx clog --color red --style bright "Message d'erreur important" / clog --color red --style bright "Message d'erreur important"
|
|
95
|
-
|
|
96
|
-
clog --color red --style bright "Message d'erreur important" / clog --color red --style bright "Message d'erreur important"
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## 📚 Documentation Complète
|
|
100
|
-
|
|
101
|
-
Pour plus d'informations sur les fonctionnalités avancées, consultez la [documentation complète](https://github.com/OrssiMp/chromalogger#readme).
|
|
102
|
-
|
|
103
|
-
## 🤝 Contribuer
|
|
104
|
-
|
|
105
|
-
Les contributions sont les bienvenues ! Voici comment contribuer :
|
|
106
|
-
|
|
107
|
-
1. Forkez le projet
|
|
108
|
-
2. Créez une branche pour votre fonctionnalité (`git checkout -b feature/AmazingFeature`)
|
|
109
|
-
3. Committez vos changements (`git commit -m 'Add some AmazingFeature'`)
|
|
110
|
-
4. Poussez vers la branche (`git push origin feature/AmazingFeature`)
|
|
111
|
-
5. Ouvrez une Pull Request
|
|
112
|
-
|
|
113
|
-
## 📄 Licence
|
|
114
|
-
|
|
115
|
-
Distribué sous licence MIT. Voir le fichier `LICENSE` pour plus d'informations.
|
|
116
|
-
|
|
117
|
-
## 📞 Contact
|
|
118
|
-
|
|
119
|
-
Orssi Mp - [@OrssiMp](https://github.com/OrssiMp) - orssimpiere5@gmail.com
|
|
120
|
-
|
|
121
|
-
Lien du projet : [https://github.com/OrssiMp/chromalogger](https://github.com/OrssiMp/chromalogger)
|
|
122
|
-
|
|
123
|
-
// Couleurs de base
|
|
124
|
-
logger.red('Ceci est en rouge');
|
|
125
|
-
logger.green('Ceci est en vert');
|
|
126
|
-
logger.blue('Ceci est en bleu');
|
|
127
|
-
logger.yellow('Ceci est en jaune');
|
|
128
|
-
|
|
129
|
-
````
|
|
130
|
-
|
|
131
|
-
### Avec CommonJS
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
const logger = require('logcolor-js');
|
|
135
|
-
|
|
136
|
-
// Arrière-plans colorés
|
|
137
|
-
logger.bgRed(' Fond rouge ');
|
|
138
|
-
logger.bgGreen(' Fond vert ');
|
|
139
|
-
logger.bgBlue(' Fond bleu ');
|
|
140
|
-
````
|
|
141
|
-
|
|
142
|
-
## Fonctionnalités
|
|
143
|
-
|
|
144
|
-
### Couleurs de texte
|
|
145
|
-
|
|
146
|
-
- `red(text)` - Texte rouge
|
|
147
|
-
- `green(text)` - Texte vert
|
|
148
|
-
- `blue(text)` - Texte bleu
|
|
149
|
-
- `yellow(text)` - Texte jaune
|
|
150
|
-
- `white(text)` - Texte blanc
|
|
151
|
-
- `black(text)` - Texte noir
|
|
152
|
-
- `magenta(text)` - Texte magenta
|
|
153
|
-
- `cyan(text)` - Texte cyan
|
|
154
|
-
|
|
155
|
-
### Arrière-plans
|
|
156
|
-
|
|
157
|
-
- `bgRed(text)` - Fond rouge
|
|
158
|
-
- `bgGreen(text)` - Fond vert
|
|
159
|
-
- `bgBlue(text)` - Fond bleu
|
|
160
|
-
- `bgYellow(text)` - Fond jaune
|
|
161
|
-
- `bgWhite(text)` - Fond blanc
|
|
162
|
-
- `bgBlack(text)` - Fond noir
|
|
163
|
-
- `bgMagenta(text)` - Fond magenta
|
|
164
|
-
- `bgCyan(text)` - Fond cyan
|
|
165
|
-
|
|
166
|
-
### Styles de texte
|
|
167
|
-
|
|
168
|
-
- `bold(text)` - Texte en gras
|
|
169
|
-
- `underline(text)` - Texte souligné
|
|
170
|
-
- `italic(text)` - Texte en italique
|
|
171
|
-
- `inverse(text)` - Inverse les couleurs
|
|
172
|
-
- `strikethrough(text)` - Texte barré
|
|
173
|
-
|
|
174
|
-
### Niveaux de log
|
|
175
|
-
|
|
176
|
-
- `setLogLevel(level)` - Définit le niveau de log ('DEBUG', 'INFO', 'WARN', 'ERROR')
|
|
177
|
-
- `debug(...args)` - Message de débogage
|
|
178
|
-
- `info(...args)` - Information
|
|
179
|
-
- `warn(...args)` - Avertissement
|
|
180
|
-
- `error(...args)` - Erreur
|
|
181
|
-
- `success(...args)` - Succès (alias pour info avec icône de succès)
|
|
182
|
-
- `warning(...args)` - Avertissement (alias pour warn avec icône d'avertissement)
|
|
183
|
-
|
|
184
|
-
## Exemples avancés
|
|
185
|
-
|
|
186
|
-
### Combinaison de styles
|
|
187
|
-
|
|
188
|
-
```javascript
|
|
189
|
-
// Combinaison de styles
|
|
190
|
-
logger.bold(logger.red('Texte en gras et rouge'));
|
|
191
|
-
logger.bgBlue(logger.white('Texte blanc sur fond bleu'));
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Niveaux de log
|
|
195
|
-
|
|
196
|
-
```javascript
|
|
197
|
-
// Définir le niveau de log (par défaut: 'INFO')
|
|
198
|
-
logger.setLogLevel('DEBUG');
|
|
199
|
-
|
|
200
|
-
// Messages de log
|
|
201
|
-
logger.debug('Message de débogage');
|
|
202
|
-
logger.info('Information');
|
|
203
|
-
logger.warn('Avertissement');
|
|
204
|
-
logger.error('Erreur');
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Avec des objets et tableaux
|
|
208
|
-
|
|
209
|
-
```javascript
|
|
210
|
-
// Objets
|
|
211
|
-
const user = {
|
|
212
|
-
name: 'John',
|
|
213
|
-
age: 30,
|
|
214
|
-
roles: ['admin', 'user'],
|
|
215
|
-
};
|
|
216
|
-
logger.info('Utilisateur:', user);
|
|
217
|
-
|
|
218
|
-
// Tableaux
|
|
219
|
-
const numbers = [1, 2, 3, 4, 5];
|
|
220
|
-
logger.info('Nombres:', numbers);
|
|
221
|
-
|
|
222
|
-
// Références circulaires
|
|
223
|
-
const obj1 = { name: 'Objet 1' };
|
|
224
|
-
const obj2 = { name: 'Objet 2', ref: obj1 };
|
|
225
|
-
obj1.ref = obj2;
|
|
226
|
-
logger.info('Objet avec référence circulaire:', obj1);
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
## Personnalisation
|
|
230
|
-
|
|
231
|
-
### Styles personnalisés
|
|
232
|
-
|
|
233
|
-
```javascript
|
|
234
|
-
// Accès direct aux codes ANSI
|
|
235
|
-
console.log(
|
|
236
|
-
`${logger.styles.bold}${logger.styles.red}Texte en gras et rouge${logger.styles.reset}`
|
|
237
|
-
);
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### Templates
|
|
241
|
-
|
|
242
|
-
```javascript
|
|
243
|
-
const name = 'Alice';
|
|
244
|
-
const age = 30;
|
|
245
|
-
logger.info('Nom: {0}, Âge: {1}', name, age);
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## Contribution
|
|
249
|
-
|
|
250
|
-
Les contributions sont les bienvenues ! N'hésitez pas à ouvrir une issue ou une pull request.
|
|
251
|
-
|
|
252
|
-
## Licence
|
|
253
|
-
|
|
254
|
-
MIT
|
|
1
|
+
# ChromaLogger
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/chromalogger)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://github.com/OrssiMp/chromalogger/stargazers)
|
|
6
|
+
|
|
7
|
+
[🇬🇧 English](README.md) | [🇫🇷 Français](README.fr.md)
|
|
8
|
+
|
|
9
|
+
ChromaLogger is a powerful and flexible Node.js console logging library with advanced support for colors, styles, and debugging features. Perfect for Node.js application development and debugging.
|
|
10
|
+
|
|
11
|
+
## 🚀 Features
|
|
12
|
+
|
|
13
|
+
- 🌈 Rich color and style support (16+ colors, text formatting)
|
|
14
|
+
- 📊 Built-in log levels (DEBUG, INFO, WARN, ERROR)
|
|
15
|
+
- 🔄 Circular reference detection
|
|
16
|
+
- 📝 Template string support
|
|
17
|
+
- 🛠️ Customizable loggers
|
|
18
|
+
- 💻 CLI tool included
|
|
19
|
+
- 🔌 Extensible architecture
|
|
20
|
+
|
|
21
|
+
## 📦 Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# With npm
|
|
25
|
+
npm install chromalogger
|
|
26
|
+
|
|
27
|
+
# Or with Yarn
|
|
28
|
+
yarn add chromalogger
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 💡 Quick Start
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import { log, info, warn, error, createLogger } from 'chromalogger';
|
|
35
|
+
|
|
36
|
+
// Basic usage
|
|
37
|
+
log('This is a log message');
|
|
38
|
+
info('Informational message');
|
|
39
|
+
warn('Warning message');
|
|
40
|
+
error('Error message');
|
|
41
|
+
|
|
42
|
+
// With styles
|
|
43
|
+
const success = createLogger('green', 'bold');
|
|
44
|
+
success('Operation completed successfully!');
|
|
45
|
+
|
|
46
|
+
// Template strings
|
|
47
|
+
const user = { name: 'Alice', age: 30 };
|
|
48
|
+
info('User {0} is {1} years old', user.name, user.age);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 📚 Documentation
|
|
52
|
+
|
|
53
|
+
For complete documentation, please visit our [GitHub Wiki](https://github.com/yourusername/chromalogger/wiki).
|
|
54
|
+
|
|
55
|
+
## 🤝 Contributing
|
|
56
|
+
|
|
57
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) to get started.
|
|
58
|
+
|
|
59
|
+
## 📄 License
|
|
60
|
+
|
|
61
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
62
|
+
|
|
63
|
+
## 🙏 Acknowledgments
|
|
64
|
+
|
|
65
|
+
- Inspired by popular logging libraries like chalk, winston, and debug
|
|
66
|
+
- Thanks to all contributors who have helped improve this project
|