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 ADDED
@@ -0,0 +1,253 @@
1
+ # Chroma Utility
2
+
3
+ [🇬🇧 English](#chroma-utility) | [🇫🇷 Français](#utilitaire-chroma)
4
+
5
+ ## Chroma Utility
6
+
7
+ Chroma is a simple utility function for styling console text output in Node.js applications. It's part of the ChromaLogger package and provides a convenient way to apply ANSI color and style codes to your console output.
8
+
9
+ ## 🔧 Installation
10
+
11
+ Chroma is included with ChromaLogger. No additional installation is needed if you already have ChromaLogger installed.
12
+
13
+ ```bash
14
+ # If you need to install ChromaLogger
15
+ npm install chromalogger
16
+ # or
17
+ yarn add chromalogger
18
+ ```
19
+
20
+ ## 🚀 Quick Start
21
+
22
+ ```javascript
23
+ import chroma from 'chromalogger/utils/chroma.js';
24
+
25
+ // Basic usage
26
+ chroma('This text is red and bold', 'red', 'bright');
27
+
28
+ // Multiple styles
29
+ chroma('Blue text on white background', 'blue', 'bgWhite');
30
+
31
+ // Using with template literals
32
+ const name = 'Alice';
33
+ chroma(`Hello, ${name}!`, 'green', 'underline');
34
+ ```
35
+
36
+ ## 📚 API Reference
37
+
38
+ ### `chroma(text, ...styleNames)`
39
+
40
+ Applies the specified styles to the text and logs it to the console.
41
+
42
+ **Parameters:**
43
+ - `text` (string): The text to style and log
44
+ - `...styleNames` (string): One or more style names to apply
45
+
46
+ **Returns:** `undefined`
47
+
48
+ ## 🎨 Available Styles
49
+
50
+ ### Text Colors
51
+ - `black`
52
+ - `red`
53
+ - `green`
54
+ - `yellow`
55
+ - `blue`
56
+ - `magenta`
57
+ - `cyan`
58
+ - `white`
59
+
60
+ ### Background Colors
61
+ - `bgBlack`
62
+ - `bgRed`
63
+ - `bgGreen`
64
+ - `bgYellow`
65
+ - `bgBlue`
66
+ - `bgMagenta`
67
+ - `bgCyan`
68
+ - `bgWhite`
69
+
70
+ ### Text Styles
71
+ - `bright` (bold)
72
+ - `dim`
73
+ - `italic`
74
+ - `underline`
75
+ - `blink`
76
+ - `reverse` (swap foreground and background)
77
+ - `hidden`
78
+ - `strikethrough`
79
+
80
+ ## 📝 Examples
81
+
82
+ ### Basic Usage
83
+
84
+ ```javascript
85
+ import chroma from 'chromalogger/utils/chroma.js';
86
+
87
+ // Simple colored text
88
+ chroma('Error: Something went wrong!', 'red');
89
+
90
+ // Multiple styles
91
+ chroma('Warning: This is important!', 'yellow', 'bright', 'underline');
92
+
93
+ // Background color
94
+ chroma('Success!', 'green', 'bgBlack');
95
+ ```
96
+
97
+ ### Advanced Usage
98
+
99
+ ```javascript
100
+ // Create reusable styled log functions
101
+ const success = (text) => chroma(text, 'green', 'bright');
102
+ const error = (text) => chroma(text, 'red', 'bright');
103
+ const warning = (text) => chroma(text, 'yellow', 'bright');
104
+
105
+ // Use them throughout your application
106
+ success('Operation completed successfully!');
107
+ error('Failed to connect to the server');
108
+ warning('This feature is deprecated');
109
+
110
+ // Conditional styling
111
+ const status = 'success';
112
+ chroma(
113
+ `Status: ${status}`,
114
+ status === 'success' ? 'green' : 'red',
115
+ 'bright'
116
+ );
117
+ ```
118
+
119
+ ## ⚠️ Notes
120
+
121
+ - Chroma is designed for Node.js environments with console support
122
+ - Colors may not display correctly in all terminals
123
+ - For more complex logging needs, consider using the full ChromaLogger package
124
+
125
+ ## 📄 License
126
+
127
+ MIT - See [LICENSE](LICENSE) for more information.
128
+
129
+ ---
130
+
131
+ ## Utilitaire Chroma
132
+
133
+ [🇬🇧 English](#chroma-utility) | [🇫🇷 Français](#utilitaire-chroma)
134
+
135
+ ## 📦 Installation
136
+
137
+ Chroma est inclus avec ChromaLogger. Aucune installation supplémentaire n'est nécessaire si vous avez déjà installé ChromaLogger.
138
+
139
+ ```bash
140
+ # Si vous devez installer ChromaLogger
141
+ npm install chromalogger
142
+ # ou
143
+ yarn add chromalogger
144
+ ```
145
+
146
+ ## 🚀 Démarrage Rapide
147
+
148
+ ```javascript
149
+ import chroma from 'chromalogger/utils/chroma.js';
150
+
151
+ // Utilisation de base
152
+ chroma('Ce texte est en rouge et en gras', 'red', 'bright');
153
+
154
+ // Styles multiples
155
+ chroma('Texte bleu sur fond blanc', 'blue', 'bgWhite');
156
+
157
+ // Avec des littéraux de gabarit
158
+ const nom = 'Alice';
159
+ chroma(`Bonjour, ${nom} !`, 'green', 'underline');
160
+ ```
161
+
162
+ ## 📚 Référence de l'API
163
+
164
+ ### `chroma(texte, ...nomsStyles)`
165
+
166
+ Applique les styles spécifiés au texte et l'affiche dans la console.
167
+
168
+ **Paramètres :**
169
+ - `texte` (string) : Le texte à styliser et à afficher
170
+ - `...nomsStyles` (string) : Un ou plusieurs noms de styles à appliquer
171
+
172
+ **Retourne :** `undefined`
173
+
174
+ ## 🎨 Styles Disponibles
175
+
176
+ ### Couleurs de texte
177
+ - `black` (noir)
178
+ - `red` (rouge)
179
+ - `green` (vert)
180
+ - `yellow` (jaune)
181
+ - `blue` (bleu)
182
+ - `magenta` (magenta)
183
+ - `cyan` (cyan)
184
+ - `white` (blanc)
185
+
186
+ ### Couleurs d'arrière-plan
187
+ - `bgBlack` (fond noir)
188
+ - `bgRed` (fond rouge)
189
+ - `bgGreen` (fond vert)
190
+ - `bgYellow` (fond jaune)
191
+ - `bgBlue` (fond bleu)
192
+ - `bgMagenta` (fond magenta)
193
+ - `bgCyan` (fond cyan)
194
+ - `bgWhite` (fond blanc)
195
+
196
+ ### Styles de texte
197
+ - `bright` (gras)
198
+ - `dim` (atténué)
199
+ - `italic` (italique)
200
+ - `underline` (souligné)
201
+ - `blink` (clignotant)
202
+ - `reverse` (inverse les couleurs)
203
+ - `hidden` (caché)
204
+ - `strikethrough` (barré)
205
+
206
+ ## 📝 Exemples
207
+
208
+ ### Utilisation de Base
209
+
210
+ ```javascript
211
+ import chroma from 'chromalogger/utils/chroma.js';
212
+
213
+ // Texte coloré simple
214
+ chroma('Erreur : Quelque chose a mal tourné !', 'red');
215
+
216
+ // Styles multiples
217
+ chroma('Attention : Ceci est important !', 'yellow', 'bright', 'underline');
218
+
219
+ // Couleur d'arrière-plan
220
+ chroma('Succès !', 'green', 'bgBlack');
221
+ ```
222
+
223
+ ### Utilisation Avancée
224
+
225
+ ```javascript
226
+ // Créer des fonctions de log réutilisables
227
+ const succes = (texte) => chroma(texte, 'green', 'bright');
228
+ const erreur = (texte) => chroma(texte, 'red', 'bright');
229
+ const avertissement = (texte) => chroma(texte, 'yellow', 'bright');
230
+
231
+ // Les utiliser dans votre application
232
+ succes('Opération réussie !');
233
+ erreur('Échec de la connexion au serveur');
234
+ avertissement('Cette fonctionnalité est obsolète');
235
+
236
+ // Style conditionnel
237
+ const statut = 'succes';
238
+ chroma(
239
+ `Statut : ${statut}`,
240
+ statut === 'succes' ? 'green' : 'red',
241
+ 'bright'
242
+ );
243
+ ```
244
+
245
+ ## ⚠️ Notes
246
+
247
+ - Chroma est conçu pour les environnements Node.js avec support de la console
248
+ - Les couleurs peuvent ne pas s'afficher correctement dans tous les terminaux
249
+ - Pour des besoins de journalisation plus complexes, envisagez d'utiliser le module ChromaLogger complet
250
+
251
+ ## 📄 Licence
252
+
253
+ MIT - Voir [LICENCE](LICENSE) pour plus d'informations.
package/INFO.md ADDED
@@ -0,0 +1,128 @@
1
+ # Guide d'utilisation des niveaux de log
2
+
3
+ Ce document explique comment utiliser efficacement les différents niveaux de log dans la bibliothèque ChromaLogger.
4
+
5
+ ## Table des matières
6
+
7
+ - [Introduction aux niveaux de log](#introduction-aux-niveaux-de-log)
8
+ - [Les différents niveaux disponibles](#les-différents-niveaux-disponibles)
9
+ - [Comment définir le niveau de log](#comment-définir-le-niveau-de-log)
10
+ - [Exemples d'utilisation](#exemples-dutilisation)
11
+ - [Bonnes pratiques](#bonnes-pratiques)
12
+ - [Dépannage](#dépannage)
13
+
14
+ ## Introduction aux niveaux de log
15
+
16
+ Les niveaux de log vous permettent de contrôler la quantité d'informations affichées dans vos journaux. Cela est particulièrement utile pour :
17
+
18
+ - Déboguer des problèmes en production
19
+ - Réduire le bruit dans les logs en production
20
+ - Activer/désactiver des logs détaillés selon l'environnement
21
+
22
+ ## Les différents niveaux disponibles
23
+
24
+ La bibliothèque supporte 5 niveaux de log, du plus bas au plus élevé :
25
+
26
+ | Niveau | Valeur | Description |
27
+ | ------- | ------ | -------------------------------------------------------- |
28
+ | `DEBUG` | 0 | Niveau le plus détaillé, utilisé pour le débogage |
29
+ | `INFO` | 1 | Informations générales sur le déroulement du programme |
30
+ | `WARN` | 2 | Situations potentiellement problématiques |
31
+ | `ERROR` | 3 | Erreurs qui n'empêchent pas l'application de fonctionner |
32
+ | `NONE` | 4 | Aucun log ne sera affiché |
33
+
34
+ ## Comment définir le niveau de log
35
+
36
+ Utilisez la fonction `setLogLevel()` pour définir le niveau de log :
37
+
38
+ ```javascript
39
+ import { setLogLevel, LOG_LEVELS } from './index.js';
40
+
41
+ // Méthode 1 : Utiliser le nom du niveau
42
+ setLogLevel('DEBUG'); // Affiche tous les messages
43
+ setLogLevel('INFO'); // Affiche INFO, WARN et ERROR
44
+ setLogLevel('WARN'); // Affiche WARN et ERROR
45
+ setLogLevel('ERROR'); // Affiche uniquement les erreurs
46
+ setLogLevel('NONE'); // Désactive tous les logs
47
+
48
+ // Méthode 2 : Utiliser la constante LOG_LEVELS
49
+ setLogLevel(LOG_LEVELS.DEBUG);
50
+ ```
51
+
52
+ ## Exemples d'utilisation
53
+
54
+ ### Configuration de base
55
+
56
+ ```javascript
57
+ import { setLogLevel, log, debug, info, warn, error } from './index.js';
58
+
59
+ // Définir le niveau de log (par défaut: INFO)
60
+ setLogLevel('DEBUG');
61
+
62
+ // Ces logs s'afficheront selon le niveau défini
63
+ debug('Message de débogage'); // Niveau DEBUG (0)
64
+ log('Message standard'); // Niveau INFO (1)
65
+ info('Information'); // Niveau INFO (1)
66
+ warn('Avertissement'); // Niveau WARN (2)
67
+ error('Erreur'); // Niveau ERROR (3)
68
+ ```
69
+
70
+ ### Utilisation dans différents environnements
71
+
72
+ ```javascript
73
+ // Dans votre configuration d'environnement
74
+ const environment = process.env.NODE_ENV || 'development';
75
+
76
+ // Définir le niveau de log selon l'environnement
77
+ if (environment === 'production') {
78
+ setLogLevel('WARN'); // En production, on ne veut que les avertissements et erreurs
79
+ } else {
80
+ setLogLevel('DEBUG'); // En développement, on veut tout voir
81
+ }
82
+ ```
83
+
84
+ ## Bonnes pratiques
85
+
86
+ 1. **Environnement de développement** : Utilisez `DEBUG` ou `INFO` pour avoir un maximum d'informations
87
+ 2. **Environnement de test** : Utilisez `INFO` pour suivre l'exécution des tests
88
+ 3. **Environnement de production** : Utilisez `WARN` ou `ERROR` pour éviter la surcharge de logs
89
+ 4. **Pour le débogage** : Passez temporairement en `DEBUG` pour résoudre des problèmes spécifiques
90
+ 5. **Évitez les logs inutiles** : Ne laissez pas de logs de débogage en production
91
+
92
+ ## Dépannage
93
+
94
+ ### Problème : Mes logs ne s'affichent pas
95
+
96
+ 1. Vérifiez que le niveau de log est correctement défini :
97
+
98
+ ```javascript
99
+ import { setLogLevel } from './index.js';
100
+ setLogLevel('DEBUG'); // Pour voir tous les logs
101
+ ```
102
+
103
+ 2. Vérifiez que vous utilisez la bonne fonction de log :
104
+ - `log()` et `info()` : Niveau INFO (1)
105
+ - `debug()` : Niveau DEBUG (0)
106
+ - `warn()` : Niveau WARN (2)
107
+ - `error()` : Niveau ERROR (3)
108
+
109
+ ### Problème : Trop de logs en production
110
+
111
+ Augmentez le niveau de log pour réduire le bruit :
112
+
113
+ ```javascript
114
+ // En production
115
+ setLogLevel('WARN'); // N'affiche que les avertissements et erreurs
116
+ ```
117
+
118
+ ### Problème : Les logs sont désactivés
119
+
120
+ Vérifiez que le niveau n'est pas défini sur `NONE` :
121
+
122
+ ```javascript
123
+ setLogLevel('INFO'); // Réactive les logs d'information et supérieurs
124
+ ```
125
+
126
+ ## Conclusion
127
+
128
+ La gestion des niveaux de log est un outil puissant pour maintenir et déboguer vos applications. En utilisant correctement les différents niveaux, vous pouvez garder une trace utile de ce qui se passe dans votre application sans être submergé par trop d'informations.