chromalogger 1.1.2 → 1.3.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Votre Nom
3
+ Copyright (c) 2025 Orssi Mp
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,66 +1,100 @@
1
1
  # ChromaLogger
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/chromalogger.svg?style=flat)](https://www.npmjs.com/package/chromalogger)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![GitHub stars](https://img.shields.io/github/stars/OrssiMp/chromalogger.svg?style=social)](https://github.com/OrssiMp/chromalogger/stargazers)
3
+ > A powerful and colorful logger for Node.js with advanced formatting
6
4
 
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
5
+ ## Installation
22
6
 
23
7
  ```bash
24
- # With npm
25
8
  npm install chromalogger
9
+ ```
26
10
 
27
- # Or with Yarn
28
- yarn add chromalogger
11
+ ## Basic Usage
12
+
13
+ ```javascript
14
+ import { logger } from 'chromalogger';
15
+
16
+ // Basic logging
17
+ logger.info('This is an info message');
18
+ logger.success('Operation completed successfully!');
19
+ logger.warn('This is a warning');
20
+ logger.error('An error occurred');
29
21
  ```
30
22
 
31
- ## 💡 Quick Start
23
+ ## Advanced Formatting
24
+
25
+ ChromaLogger provides a flexible `format()` method for custom styling:
32
26
 
33
27
  ```javascript
34
- import { log, info, warn, error, createLogger } from 'chromalogger';
28
+ // Single style
29
+ logger.format(colors.red, 'This text will be red');
35
30
 
36
- // Basic usage
37
- log('This is a log message');
38
- info('Informational message');
39
- warn('Warning message');
40
- error('Error message');
31
+ // Multiple styles combined
32
+ logger.format(
33
+ [colors.bold, colors.bgBlue, colors.white],
34
+ 'Bold white text on blue background'
35
+ );
41
36
 
42
- // With styles
43
- const success = createLogger('green', 'bold');
44
- success('Operation completed successfully!');
37
+ // With timestamps
38
+ logger.setTimestamp(true);
39
+ logger.format(colors.green, 'This will include a timestamp');
45
40
 
46
- // Template strings
47
- const user = { name: 'Alice', age: 30 };
48
- info('User {0} is {1} years old', user.name, user.age);
41
+ // Create reusable themes
42
+ const errorTheme = [colors.bright, colors.red];
43
+ const successTheme = [colors.bright, colors.green];
44
+
45
+ logger.format(errorTheme, 'Error: Something went wrong!');
46
+ logger.format(successTheme, 'Success: Operation completed!');
49
47
  ```
50
48
 
51
- ## 📚 Documentation
49
+ ### Available Styles
50
+
51
+ ChromaLogger includes several built-in styles:
52
+
53
+ - **Text Colors**: black, red, green, yellow, blue, magenta, cyan, white
54
+ - **Background Colors**: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
55
+ - **Text Styles**: bright, dim, italic, underline, blink, reverse, hidden
56
+
57
+ ## Features
58
+
59
+ - Colorful console output
60
+ - Advanced formatting options
61
+ - Optional timestamps
62
+ - Reusable style themes
63
+ - Browser support with styled console groups
52
64
 
53
- For complete documentation, please visit our [GitHub Wiki](https://github.com/yourusername/chromalogger/wiki).
65
+ ## Browser Support
66
+
67
+ ChromaLogger works in modern browsers with full styling support:
68
+
69
+ ```javascript
70
+ // In your browser code
71
+ import { browser } from 'chromalogger';
72
+
73
+ // All logging methods work in the browser
74
+ browser.info('Browser info message');
75
+ browser.success('Operation completed in browser!');
76
+ browser.warn('Browser warning');
77
+ browser.error('Browser error occurred');
78
+
79
+ // With timestamps
80
+ browser.setTimestamp(true);
81
+ browser.info('This message has a timestamp');
82
+ ```
54
83
 
55
- ## 🤝 Contributing
84
+ ### Browser-Specific Features
56
85
 
57
- Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) to get started.
86
+ - **Collapsible Groups**: Info and success logs are displayed in collapsible groups
87
+ - **Native Console Methods**: Uses `console.warn` and `console.error` for warnings and errors
88
+ - **Responsive Design**: Logs adapt to the browser's console width
58
89
 
59
- ## 📄 License
90
+ ### Supported Browsers
60
91
 
61
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
92
+ - Chrome 30+
93
+ - Firefox 25+
94
+ - Edge 12+
95
+ - Safari 7+
96
+ - Opera 15+
62
97
 
63
- ## 🙏 Acknowledgments
98
+ ## License
64
99
 
65
- - Inspired by popular logging libraries like chalk, winston, and debug
66
- - Thanks to all contributors who have helped improve this project
100
+ MIT
package/index.js CHANGED
@@ -1,61 +1,10 @@
1
- /**
2
- * ChromaLog - A powerful console logger with rich formatting and styling
3
- * @module chromalog
4
- * @example
5
- * // Importation de base
6
- * import chromalog from './index.js';
7
- *
8
- * // Utilisation des loggers prédéfinis
9
- * chromalog.info('Message informatif');
10
- * chromalog.error('Erreur critique!');
11
- *
12
- * // Création d'un logger personnalisé
13
- * const myLogger = chromalog.createLogger('green', 'underline');
14
- * myLogger('Message personnalisé');
15
- */
16
-
17
- // Import core modules
18
- import * as styles from './core/styles.js';
19
- import {
20
- createLogger,
21
- formatMessage,
22
- setLogLevel,
23
- LOG_LEVELS,
24
- } from './core/loggers/consoleLogger.js';
25
- import { formatObject } from './core/formatters/objectFormatter.js';
26
-
27
- // Créer les loggers avec leurs styles respectifs
28
- const log = createLogger();
29
- const debug = createLogger('dim');
30
- const info = createLogger('cyan');
31
- const warn = createLogger('yellow');
32
- const error = createLogger('red');
33
-
34
- /**
35
- * ChromaLog - A powerful console logger with rich formatting and styling
36
- */
37
- const ChromaLog = {
38
- // Core
39
- styles,
40
- createLogger,
41
- formatMessage,
42
- formatObject,
43
- setLogLevel,
44
- LOG_LEVELS: { ...LOG_LEVELS },
45
-
46
- // Loggers
47
- log: (...args) => log(...args),
48
- debug: (...args) => debug(...args),
49
- info: (...args) => info(...args),
50
- warn: (...args) => warn(...args),
51
- error: (...args) => error(...args),
52
- };
53
-
54
- // Exporter les loggers individuellement
55
- export { log, debug, info, warn, error };
56
-
57
- // Exporter les fonctions utilitaires
58
- export { styles, createLogger, formatMessage, formatObject, setLogLevel, LOG_LEVELS };
59
-
60
- // Exporter par défaut l'objet ChromaLog
61
- export default ChromaLog;
1
+ export * from './modules/chromalog.js';
2
+ export * from './modules/chromalog.browser.js';
3
+
4
+ import { logger } from './modules/chromalog.js';
5
+ import { browser } from './modules/chromalog.browser.js';
6
+
7
+ export { logger, browser };
8
+
9
+ export default logger;
10
+
package/package.json CHANGED
@@ -1,22 +1,18 @@
1
1
  {
2
2
  "name": "chromalogger",
3
- "version": "1.1.2",
3
+ "version": "1.3.0",
4
4
  "description": "A colorful and flexible console logger for Node.js with CLI support",
5
- "main": "chromalog.js",
5
+ "main": "index.js",
6
+ "browser": "chromalog.browser.js",
6
7
  "type": "module",
7
- "bin": {
8
- "clog": "./cli.js"
9
- },
8
+ "files": [
9
+ "index.js",
10
+ "chromalog.js",
11
+ "chromalog.browser.js"
12
+ ],
13
+ "browserslist": "> 0.5%, last 2 versions, not dead",
10
14
  "scripts": {
11
- "test": "node test.js",
12
- "test:watch": "nodemon --watch chromalog.js --watch test.js --exec \"npm test\"",
13
- "lint": "eslint .",
14
- "test:chroma": "node chromatest.js",
15
- "test:cli": "node clitest.js",
16
- "test:all": "npm run test && npm run test:chroma && npm run test:cli",
17
- "format": "prettier --write .",
18
- "fix": "eslint --fix .",
19
- "coverage": "c8 npm test"
15
+ "test": "node ./ideas/demo.js"
20
16
  },
21
17
  "keywords": [
22
18
  "log",
@@ -48,16 +44,5 @@
48
44
  },
49
45
  "engines": {
50
46
  "node": ">=12.0.0"
51
- },
52
- "dependencies": {
53
- "util": "^0.12.5"
54
- },
55
- "devDependencies": {
56
- "c8": "^10.1.3",
57
- "eslint": "^8.0.0",
58
- "eslint-config-prettier": "^10.1.8",
59
- "eslint-plugin-prettier": "^5.5.4",
60
- "nodemon": "^3.1.11",
61
- "prettier": "^3.7.3"
62
47
  }
63
48
  }
package/.eslintrc.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "env": {
3
- "node": true,
4
- "es2021": true,
5
- "browser": true
6
- },
7
- "extends": ["eslint:recommended", "prettier"],
8
- "parserOptions": {
9
- "ecmaVersion": 2021,
10
- "sourceType": "module"
11
- },
12
- "rules": {
13
- "no-console": "off",
14
- "no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
15
- "prettier/prettier": "error"
16
- },
17
- "plugins": ["prettier"]
18
- }
package/.prettierrc DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "semi": true,
3
- "singleQuote": true,
4
- "trailingComma": "es5",
5
- "printWidth": 100,
6
- "tabWidth": 2,
7
- "bracketSpacing": true,
8
- "arrowParens": "always"
9
- }
package/CHROMA.md DELETED
@@ -1,253 +0,0 @@
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/CONTRIBUTING.md DELETED
@@ -1,43 +0,0 @@
1
- # Comment contribuer
2
-
3
- Merci de votre intérêt pour `logcolor-js` ! Voici comment vous pouvez contribuer au projet.
4
-
5
- ## Signaler un bug
6
-
7
- Si vous trouvez un bug, merci de créer une issue en suivant ces étapes :
8
-
9
- 1. Vérifiez que le bug n'a pas déjà été signalé
10
- 2. Décrivez le bug de manière claire et concise
11
- 3. Incluez des étapes pour reproduire le bug
12
- 4. Précisez le comportement attendu
13
- 5. Incluez la version de Node.js et du module
14
-
15
- ## Proposer une amélioration
16
-
17
- 1. Créez une issue pour discuter de votre idée
18
- 2. Si l'idée est acceptée, créez une branche pour votre fonctionnalité
19
- 3. Assurez-vous que les tests passent (`npm test`)
20
- 4. Soumettez une pull request
21
-
22
- ## Processus de développement
23
-
24
- 1. Forkez le dépôt
25
- 2. Installez les dépendances : `npm install`
26
- 3. Créez une branche pour votre fonctionnalité : `git checkout -b ma-nouvelle-fonctionnalite`
27
- 4. Faites vos modifications
28
- 5. Lancez les tests : `npm test`
29
- 6. Formatez votre code : `npm run format`
30
- 7. Vérifiez les erreurs de style : `npm run lint`
31
- 8. Poussez vos modifications : `git push origin ma-nouvelle-fonctionnalite`
32
- 9. Créez une Pull Request
33
-
34
- ## Directives de codage
35
-
36
- - Suivez le style de code existant
37
- - Écrivez des tests pour les nouvelles fonctionnalités
38
- - Documentez votre code avec des commentaires clairs
39
- - Gardez les commits atomiques et bien décrits
40
-
41
- ## Licence
42
-
43
- En contribuant à ce projet, vous acceptez que vos contributions soient sous la même licence que le projet (MIT).