zario 0.2.0 โ†’ 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +161 -858
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,858 +1,161 @@
1
- <div align="center">
2
-
3
- <a id="top"></a>
4
-
5
- # ๐Ÿ“ Zario
6
-
7
- ### โšก The Ultimate Minimal Logging Solution for Node.js
8
-
9
- [![npm version](https://img.shields.io/npm/v/zario?style=for-the-badge&logo=npm&color=CB3837)](https://www.npmjs.com/package/zario)
10
- [![license](https://img.shields.io/npm/l/zario?style=for-the-badge&color=green)](./LICENSE)
11
- [![downloads](https://img.shields.io/npm/dt/zario?style=for-the-badge&logo=npm&color=orange)](https://www.npmjs.com/package/zario)
12
- [![bundle size](https://img.shields.io/bundlephobia/minzip/zario?style=for-the-badge&logo=webpack&color=purple)](https://bundlephobia.com/package/zario)
13
-
14
- <br/>
15
-
16
- **Fast** โ€ข **Lightweight** โ€ข **Zero Dependencies** โ€ข **TypeScript Native**
17
-
18
- <br/>
19
-
20
- [๐Ÿ“– Documentation](#-documentation) ยท [โšก Quick Start](#-quick-start) ยท [โœจ Features](#-features) ยท [๐Ÿ’ฌ Community](#-community)
21
-
22
- <br/>
23
-
24
- ![separator](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
25
-
26
- </div>
27
-
28
- <br/>
29
-
30
- ## โœจ Highlights
31
-
32
- * โšก Super lightweight โ€” minimal footprint, fast execution
33
- * ๐ŸŽฏ Simple API โ€” intuitive methods like `info()`, `warn()`, etc.
34
- * ๐ŸŽจ Custom formatting โ€” plain text or JSON
35
- * โฑ๏ธ Automatic timestamps
36
- * ๐Ÿ“ Multiple transports
37
- * ๐Ÿงฉ Child loggers for modular logging
38
- * ๐Ÿงต Async writes โ€” keeps Node responsive
39
- * ๐Ÿ”’ Small, safe, dependency-light design
40
- * ๐ŸŒˆ Custom log levels with color support
41
-
42
- ## ๐Ÿ“ฆ Installation
43
-
44
- ```bash
45
- npm install zario
46
- ```
47
-
48
- <details>
49
- <summary>๐Ÿ“‹ Other Package Managers</summary>
50
-
51
- ```bash
52
- # Using Yarn
53
- yarn add zario
54
-
55
- # Using pnpm
56
- pnpm add zario
57
-
58
- # Using bun
59
- bun add zario
60
- ```
61
- </details>
62
-
63
- ### ๐Ÿš€ Quick Start
64
-
65
- ```js
66
- import { Logger } from "zario";
67
-
68
- const logger = new Logger({
69
- level: "info",
70
- colorize: true,
71
- transports: [{ type: "console" }],
72
- prefix: "[MyApp]",
73
- });
74
- // Start logging
75
- logger.info("๐Ÿš€ Server started on port 3000");
76
- logger.warn("โš ๏ธ High memory usage detected");
77
- logger.error("โŒ Database connection failed", { code: 500 });
78
- ```
79
-
80
- Output:
81
-
82
- ```css
83
- [MyApp] INFO ๐Ÿš€ Server started on port 3000
84
- [MyApp] WARN โš ๏ธ High memory usage detected
85
- [MyApp] ERROR โŒ Database connection failed { code: 500 }
86
- ```
87
-
88
- ### ๐Ÿ“ Log Levels
89
-
90
- <table>
91
- <thead>
92
- <tr>
93
- <th>Level</th>
94
- <th>Method</th>
95
- <th>Use Case</th>
96
- <th>Example</th>
97
- </tr>
98
- </thead>
99
- <tbody>
100
- <tr>
101
- <td>๐Ÿ” <strong>DEBUG</strong></td>
102
- <td><code>logger.debug()</code></td>
103
- <td>Detailed debugging info</td>
104
- <td>Variable values, function calls</td>
105
- </tr>
106
- <tr>
107
- <td>โ„น๏ธ <strong>INFO</strong></td>
108
- <td><code>logger.info()</code></td>
109
- <td>General information</td>
110
- <td>Server started, user logged in</td>
111
- </tr>
112
- <tr>
113
- <td>โš ๏ธ <strong>WARN</strong></td>
114
- <td><code>logger.warn()</code></td>
115
- <td>Warning messages</td>
116
- <td>Deprecated API usage, high load</td>
117
- </tr>
118
- <tr>
119
- <td>โŒ <strong>ERROR</strong></td>
120
- <td><code>logger.error()</code></td>
121
- <td>Error conditions</td>
122
- <td>Failed requests, exceptions</td>
123
- </tr>
124
- <tr>
125
- <td>๐Ÿ’€ <strong>FATAL</strong></td>
126
- <td><code>logger.fatal()</code></td>
127
- <td>Critical failures</td>
128
- <td>System crash, data corruption</td>
129
- </tr>
130
- </tbody>
131
- </table>
132
-
133
- Example:
134
-
135
- ```js
136
- logger.debug("Debugging user authentication flow");
137
- logger.info("User successfully authenticated");
138
- logger.warn("Session about to expire");
139
- logger.error("Failed to save user data");
140
- logger.fatal("Database connection lost");
141
- ```
142
-
143
- ### ๐ŸŒฑ Child Loggers
144
-
145
- Perfect when you want separate logs per module or request:
146
-
147
- ```js
148
- const main = new Logger({ prefix: "[APP]" });
149
- const db = main.createChild({ prefix: "[DB]" });
150
-
151
- main.info("App initialized");
152
- db.error("Connection timeout");
153
- ```
154
-
155
- Output:
156
-
157
- ```css
158
- [APP] [INFO] App initialized
159
- [APP][DB] [ERROR] Connection timeout
160
- ```
161
-
162
- <br/>
163
-
164
- ![separator](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
165
-
166
- <br/>
167
-
168
- ## โœจ Features
169
-
170
- ### ๐ŸŽฏ Core Features
171
-
172
- <table>
173
- <tr>
174
- <td width="33%">
175
-
176
- #### ๐Ÿš€ High Performance
177
-
178
- - **Async logging** for non-blocking I/O
179
- - **Optimized** for high-throughput apps
180
- - **Minimal overhead** in production
181
- - **Fast JSON serialization**
182
-
183
- </td>
184
- <td width="33%">
185
-
186
- #### ๐ŸŽจ Developer Experience
187
-
188
- - **Beautiful colorized output**
189
- - **TypeScript definitions**
190
- - **Intuitive API**
191
- - **Easy configuration**
192
-
193
- </td>
194
- <td width="33%">
195
-
196
- #### ๐Ÿ”ง Flexible Configuration
197
-
198
- - **Multiple transports**
199
- - **Custom formatters**
200
- - **Log level filtering**
201
- - **Metadata support**
202
- - **Custom log levels and colors**
203
-
204
- </td>
205
- </tr>
206
- </table>
207
-
208
- <br/>
209
-
210
- ### ๐Ÿ“Š Transport Options
211
-
212
- <details>
213
- <summary><strong>๐Ÿ“บ Console Transport</strong></summary>
214
-
215
- ```javascript
216
- const logger = new Logger({
217
- transports: [{
218
- type: 'console',
219
- colorize: true
220
- }]
221
- });
222
- ```
223
-
224
- Perfect for development and debugging.
225
-
226
- </details>
227
-
228
- <details>
229
- <summary><strong>๐Ÿ“ File Transport</strong></summary>
230
-
231
- ```javascript
232
- const logger = new Logger({
233
- transports: [{
234
- type: 'file',
235
- options: {
236
- path: './logs/app.log',
237
- maxSize: 10485760, // 10MB in bytes
238
- maxFiles: 5
239
- }
240
- }]
241
- });
242
- ```
243
-
244
- Ideal for production logging and auditing.
245
-
246
- </details>
247
-
248
- <details>
249
- <summary><strong>๐Ÿ”Œ Custom Transport</strong></summary>
250
-
251
- ```javascript
252
- const logger = new Logger({
253
- transports: [{
254
- type: 'custom',
255
- write: (log) => {
256
- // Send to external service
257
- sendToDatadog(log);
258
- }
259
- }]
260
- });
261
- ```
262
-
263
- Integrate with any logging service.
264
-
265
- </details>
266
-
267
- <br/>
268
-
269
- ### ๐ŸŽญ Advanced Features
270
-
271
- <table>
272
- <tr>
273
- <td>
274
-
275
- **๐Ÿท๏ธ Metadata Support**
276
- ```javascript
277
- logger.info('User login', {
278
- userId: 12345,
279
- ip: '192.168.1.1',
280
- timestamp: new Date()
281
- });
282
- ```
283
-
284
- </td>
285
- <td>
286
-
287
- **๐Ÿ” Error Tracking**
288
- ```javascript
289
- try {
290
- riskyOperation();
291
- } catch (error) {
292
- logger.error('Operation failed', error);
293
- }
294
- ```
295
-
296
- </td>
297
- </tr>
298
- <tr>
299
- <td>
300
-
301
- **๐ŸŽฏ Prefix/Namespace**
302
- ```javascript
303
- const logger = new Logger({
304
- prefix: '[MyService]'
305
- });
306
- ```
307
-
308
- </td>
309
- <td>
310
-
311
- **โš™๏ธ Environment Aware**
312
- ```javascript
313
- const logger = new Logger({
314
- level: process.env.LOG_LEVEL || 'info'
315
- });
316
- ```
317
-
318
- </td>
319
- </tr>
320
- </table>
321
-
322
- <br/>
323
-
324
- ### ๐ŸŽจ Advanced Usage: Custom Levels & Colors
325
-
326
- <details>
327
- <summary><strong>Define Custom Log Levels</strong></summary>
328
-
329
- Create your own log levels with specific priorities and colors for more granular logging.
330
-
331
- ```typescript
332
- import { Logger } from 'zario';
333
-
334
- const logger = new Logger({
335
- level: 'info',
336
- customLevels: {
337
- 'success': 6, // Higher priority than error (5).
338
- 'verbose': 1, // Lower priority than debug (2).
339
- 'critical': 7, // Highest priority.
340
- },
341
- customColors: {
342
- 'success': 'green',
343
- 'verbose': 'cyan',
344
- 'critical': 'brightRed',
345
- },
346
- transports: [
347
- { type: 'console' }
348
- ]
349
- });
350
-
351
- // Using custom levels.
352
- logger.logWithLevel('success', 'This is a success message in green!');
353
- logger.logWithLevel('verbose', 'This is a verbose message in cyan');
354
- logger.logWithLevel('critical', 'This is a critical message in bright red');
355
- ```
356
-
357
- </details>
358
-
359
- <details>
360
- <summary><strong>Log Level Filtering</strong></summary>
361
-
362
- Set the logger's `level` to a custom level to filter messages based on their priority.
363
-
364
- ```typescript
365
- // Only logs levels with priority >= 7 (critical in this case).
366
- const highLevelLogger = new Logger({
367
- level: 'critical',
368
- customLevels: {
369
- 'success': 6,
370
- 'verbose': 1,
371
- 'critical': 7,
372
- },
373
- transports: [
374
- { type: 'console' }
375
- ]
376
- });
377
-
378
- // This will NOT be shown (verbose has priority 1 < critical threshold 7).
379
- highLevelLogger.logWithLevel('verbose', 'This will not appear');
380
-
381
- // This WILL be shown (critical has priority 7 >= threshold 7).
382
- highLevelLogger.logWithLevel('critical', 'This critical message appears');
383
- ```
384
- </details>
385
-
386
- <details>
387
- <summary><strong>Child Logger with Custom Levels</strong></summary>
388
-
389
- Child loggers inherit custom levels and colors from their parent, and can also have their own.
390
-
391
- ```typescript
392
- const parentLogger = new Logger({
393
- level: 'info',
394
- customLevels: {
395
- 'parent_custom': 6,
396
- },
397
- customColors: {
398
- 'parent_custom': 'blue',
399
- },
400
- transports: [
401
- { type: 'console' }
402
- ]
403
- });
404
-
405
- // Child will inherit parent's custom levels and can add its own.
406
- const childLogger = parentLogger.createChild({
407
- customLevels: {
408
- 'child_custom': 7, // Add child-specific level.
409
- },
410
- customColors: {
411
- 'child_custom': 'red',
412
- }
413
- });
414
-
415
- childLogger.logWithLevel('parent_custom', 'Inherited from parent');
416
- childLogger.logWithLevel('child_custom', 'Defined in child');
417
- ```
418
- </details>
419
-
420
- <br/>
421
-
422
- ![separator](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
423
-
424
- <br/>
425
-
426
- ## ๐Ÿ’ก Use Cases
427
-
428
- <table>
429
- <tr>
430
- <td width="50%">
431
-
432
- ### ๐ŸŒ Web Applications
433
-
434
- ```javascript
435
- import express from 'express';
436
- import Logger from 'zario';
437
-
438
- const app = express();
439
- const logger = new Logger({ prefix: '[API]' });
440
-
441
- app.use((req, res, next) => {
442
- const reqLogger = logger.createChild({ prefix: `[${req.method} ${req.url}]` });
443
- reqLogger.info("Incoming request");
444
- next();
445
- });
446
-
447
- app.get("/", (req, res) => {
448
- res.send("Hello!");
449
- });
450
-
451
- app.listen(3000, () => {
452
- logger.info("API running on port 3000");
453
- });
454
- ```
455
-
456
- **Perfect for:**
457
- - Express.js applications
458
- - Fastify servers
459
- - Koa.js projects
460
- - REST APIs
461
-
462
- </td>
463
- <td width="50%">
464
-
465
- ### โšก Serverless Functions
466
-
467
- ```javascript
468
- import Logger from 'zario';
469
-
470
- const logger = new Logger({
471
- level: 'info',
472
- transports: [{ type: 'console' }]
473
- });
474
-
475
- export async function handler(event) {
476
- logger.info('Lambda invoked', {
477
- requestId: event.requestId
478
- });
479
-
480
- try {
481
- const result = await processEvent(event);
482
- logger.info('Processing complete');
483
- return result;
484
- } catch (error) {
485
- logger.error('Processing failed', error);
486
- throw error;
487
- }
488
- }
489
- ```
490
-
491
- **Perfect for:**
492
- - AWS Lambda
493
- - Vercel Functions
494
- - Netlify Functions
495
- - Cloudflare Workers
496
-
497
- </td>
498
- </tr>
499
- <tr>
500
- <td width="50%">
501
-
502
- ### ๐Ÿ”ง CLI Applications
503
-
504
- ```javascript
505
- import Logger from 'zario';
506
-
507
- const logger = new Logger({
508
- colorize: true,
509
- prefix: '[CLI]'
510
- });
511
-
512
- async function buildProject() {
513
- logger.info('Starting build process...');
514
-
515
- logger.debug('Reading config file');
516
- logger.info('Compiling TypeScript...');
517
- logger.info('Bundling assets...');
518
-
519
- logger.info('โœ… Build completed successfully!');
520
- }
521
- ```
522
-
523
- **Perfect for:**
524
- - Command-line tools
525
- - Build scripts
526
- - DevOps automation
527
- - System utilities
528
-
529
- </td>
530
- <td width="50%">
531
-
532
- ### ๐Ÿ—๏ธ Microservices
533
-
534
- ```javascript
535
- import Logger from 'zario';
536
-
537
- // Create service-specific loggers
538
- const userService = new Logger({
539
- prefix: '[UserService]'
540
- });
541
-
542
- const paymentService = new Logger({
543
- prefix: '[PaymentService]'
544
- });
545
-
546
- const orderService = new Logger({
547
- prefix: '[OrderService]'
548
- });
549
-
550
- // Use in distributed system
551
- userService.info('User created', { id: 123 });
552
- paymentService.info('Payment processed');
553
- orderService.info('Order placed');
554
- ```
555
-
556
- **Perfect for:**
557
- - Distributed systems
558
- - Message queues
559
- - Event-driven architecture
560
- - Container deployments
561
-
562
- </td>
563
- </tr>
564
- </table>
565
-
566
- <br/>
567
-
568
- ![separator](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
569
-
570
- <br/>
571
-
572
- ## ๐Ÿงฉ Log Formats
573
-
574
- ### Plain Text (default)
575
- ```pgsql
576
- [2025-01-23 10:22:20] [INFO] User logged in
577
- ```
578
- ### JSON Format
579
- ```js
580
- const logger = new Logger({ json: true });
581
- ```
582
- Output:
583
- ```json
584
- {
585
- "timestamp": "2025-01-23T10:22:20Z",
586
- "level": "info",
587
- "message": "User logged in"
588
- }
589
- ```
590
-
591
- <br/>
592
-
593
- ## ๐Ÿ“ Recommended Project Structure
594
-
595
- ```bash
596
- /src
597
- /logs
598
- /modules
599
- database.js
600
- users.js
601
- logger.js
602
- server.js
603
- ```
604
-
605
- ### Example logger.js:
606
- ```js
607
- import Logger from "zario";
608
-
609
- export const logger = new Logger({
610
- prefix: "[API]",
611
- transports: [{ type: "console" }],
612
- });
613
- ```
614
-
615
- <br/>
616
-
617
- ## ๐Ÿงช Testing Example
618
-
619
- ```js
620
- import Logger from "zario";
621
-
622
- describe("Logger", () => {
623
- it("should log messages", () => {
624
- const logger = new Logger({ timestamp: false });
625
- logger.info("Testing logger");
626
- });
627
- });
628
- ```
629
-
630
- <br/>
631
-
632
- ## ๐Ÿ“š Full Options Reference
633
-
634
- | Option | Type | Description |
635
- | -------------- | -------- | ----------------------- |
636
- | **level** | `string` | Log level threshold |
637
- | **json** | `boolean` | Output in JSON format |
638
- | **timestamp** | `boolean` | Include timestamps |
639
- | **prefix** | `string` | Prepended label |
640
- | **transports** | `array` | Where logs are written (with transport-specific options like `path`, `maxSize`, `maxFiles` for file transport) |
641
- | **customLevels** | `object` | Define custom log levels and their priorities |
642
- | **customColors** | `object` | Assign colors to custom log levels |
643
- | **createChild()** | `method` | Creates a scoped logger |
644
-
645
- <br/>
646
-
647
- ![separator](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
648
-
649
- <br/>
650
-
651
- ## ๐Ÿ“– Documentation
652
-
653
- <div align="center">
654
-
655
- <table>
656
- <thead>
657
- <tr>
658
- <th width="30%">๐Ÿ“š Resource</th>
659
- <th width="50%">๐Ÿ“ Description</th>
660
- <th width="20%">๐Ÿ”— Link</th>
661
- </tr>
662
- </thead>
663
- <tbody>
664
- <tr>
665
- <td><strong>๐Ÿ“˜ Usage Guide</strong></td>
666
- <td>Complete guide with examples and best practices</td>
667
- <td><a href="./docs/usage.md">Read โ†’</a></td>
668
- </tr>
669
- <tr>
670
- <td><strong>โš™๏ธ Configuration</strong></td>
671
- <td>All configuration options explained in detail</td>
672
- <td><a href="./docs/configuration.md">Read โ†’</a></td>
673
- </tr>
674
- <tr>
675
- <td><strong>๐ŸŽฏ API Reference</strong></td>
676
- <td>Full API documentation with type definitions</td>
677
- <td><a href="./docs/api.md">Read โ†’</a></td>
678
- </tr>
679
- <tr>
680
- <td><strong>๐Ÿ’ผ Use Cases</strong></td>
681
- <td>Real-world examples and implementation patterns</td>
682
- <td><a href="./docs/use-cases.md">Read โ†’</a></td>
683
- </tr>
684
- <tr>
685
- <td><strong>๐Ÿš€ Migration Guide</strong></td>
686
- <td>Migrate from other logging libraries</td>
687
- <td><a href="./docs/migration.md">Read โ†’</a></td>
688
- </tr>
689
- <tr>
690
- <td><strong>๐Ÿ”Œ Custom Transports</strong></td>
691
- <td>Build your own transport implementations</td>
692
- <td><a href="./docs/transports.md">Read โ†’</a></td>
693
- </tr>
694
- </tbody>
695
- </table>
696
-
697
- </div>
698
-
699
- <br/>
700
-
701
- ![separator](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
702
-
703
- <br/>
704
-
705
- ## ๐Ÿ—บ๏ธ Roadmap
706
-
707
- <table>
708
- <tr>
709
- <td width="33%">
710
-
711
- ### ๐ŸŽฏ Coming Soon
712
-
713
- - [x] โœ… Console & File transports
714
- - [x] โœ… Child loggers
715
- - [x] โœ… TypeScript support
716
- - [x] โœ… Log rotation
717
- - [ ] ๐Ÿ”„ HTTP transport
718
- - [ ] ๐Ÿ”„ Syslog support
719
-
720
- </td>
721
- <td width="33%">
722
-
723
- ### ๐Ÿš€ Future Plans
724
-
725
- - [ ] ๐Ÿ“Š Performance metrics
726
- - [ ] ๐Ÿ” Advanced filtering
727
- - [ ] ๐Ÿ“ฑ React Native support
728
- - [x] ๐ŸŒˆ Custom themes
729
- - [ ] ๐Ÿ” Log encryption
730
- - [ ] ๐Ÿ“ˆ Analytics dashboard
731
-
732
- </td>
733
- <td width="33%">
734
-
735
- ### ๐Ÿ’ก Under Consideration
736
-
737
- - [ ] WebSocket transport
738
- - [ ] MongoDB transport
739
- - [ ] Redis transport
740
- - [ ] Elasticsearch integration
741
- - [ ] Structured logging
742
- - [ ] Log aggregation
743
-
744
- </td>
745
- </tr>
746
- </table>
747
-
748
- > ๐Ÿ—ณ๏ธ **Vote for features:** Have a feature request? [Open an issue](../../issues/new) and let us know!
749
-
750
- <br/>
751
-
752
- ![separator](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
753
-
754
- <br/>
755
-
756
- ## ๐Ÿค Contributing
757
-
758
- We โค๏ธ contributions! Whether it's bug reports, feature requests, or code contributions.
759
-
760
- <table>
761
- <tr>
762
- <td width="25%" align="center">
763
- <strong>๐Ÿ› Report Bugs</strong><br/>
764
- <sub>Found a bug?</sub><br/>
765
- <a href="../../issues/new">Report it โ†’</a>
766
- </td>
767
- <td width="25%" align="center">
768
- <strong>๐Ÿ’ก Request Features</strong><br/>
769
- <sub>Have an idea?</sub><br/>
770
- <a href="../../issues/new">Suggest it โ†’</a>
771
- </td>
772
- <td width="25%" align="center">
773
- <strong>๐Ÿ“– Improve Docs</strong><br/>
774
- <sub>Fix a typo?</sub><br/>
775
- <a href="../../pulls">Submit PR โ†’</a>
776
- </td>
777
- <td width="25%" align="center">
778
- <strong>๐Ÿ’ฌ Join Discussion</strong><br/>
779
- <sub>Questions?</sub><br/>
780
- <a href="../../discussions">Discuss โ†’</a>
781
- </td>
782
- </tr>
783
- </table>
784
-
785
- ### ๐Ÿ› ๏ธ Development Setup
786
-
787
- Follow these steps if you want to work on the project locally:
788
-
789
- ```bash
790
- # Clone the repository
791
- git clone https://github.com/Dev-Dami/zario.git
792
-
793
- # Navigate into the project
794
- cd zario
795
-
796
- # Install dependencies
797
- npm install
798
-
799
- # Run tests
800
- npm test
801
-
802
- # Build the project
803
- npm run build
804
- ```
805
-
806
- <br/>
807
-
808
- ## ๐Ÿ’ฌ Community
809
-
810
- <div align="center">
811
-
812
- [![GitHub Stars](https://img.shields.io/github/stars/Dev-Dami/zario?style=social)](../../stargazers)
813
- [![GitHub Forks](https://img.shields.io/github/forks/Dev-Dami/zario?style=social)](../../network/members)
814
- [![GitHub Issues](https://img.shields.io/github/issues/Dev-Dami/zario?style=social)](../../issues)
815
-
816
- **Join our growing community!**
817
-
818
- [๐Ÿ’ฌ Discussions](../../discussions) โ€ข [๐Ÿ› Issues](../../issues) โ€ข [๐Ÿ“ข Changelog](./CHANGELOG.md)
819
-
820
- </div>
821
-
822
- <br/>
823
-
824
- ![separator](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
825
-
826
- <br/>
827
-
828
- ## ๐Ÿ“„ License
829
-
830
- This project is licensed under the **MIT License** - see the [LICENSE](./LICENSE) file for full details.
831
-
832
- ```text
833
- MIT License - feel free to use this in your projects!
834
- ```
835
-
836
- ### Made with โค๏ธ by developers, for developers
837
-
838
- <br/>
839
-
840
- ## ๐ŸŒŸ Show Your Support
841
-
842
- If **Zario** made your logging easier, consider:
843
-
844
- <div align="center">
845
-
846
- โญ **Star this repository** to show your support
847
-
848
- ๐Ÿฆ **Share on Twitter** to spread the word
849
-
850
- โ˜• **Buy us a coffee** to fuel development
851
-
852
- [![Star History Chart](https://api.star-history.com/svg?repos=Dev-Dami/zario&type=Date)](https://star-history.com/#Dev-Dami/zario&Date)
853
-
854
- </div>
855
-
856
- <br/>
857
-
858
- [โฌ† Back to Top](#top)
1
+ # zario
2
+
3
+ A minimal, fast logging library for Node.js with TypeScript support.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install zario
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```js
14
+ import { Logger } from "zario";
15
+
16
+ const logger = new Logger({
17
+ level: "info",
18
+ colorize: true,
19
+ transports: [{ type: "console" }],
20
+ prefix: "[MyApp]",
21
+ });
22
+
23
+ // Start logging
24
+ logger.info("๐Ÿš€ Server started on port 3000");
25
+ logger.warn("โš ๏ธ High memory usage detected");
26
+ logger.error("โŒ Database connection failed", { code: 500 });
27
+ ```
28
+
29
+ ## API Documentation
30
+
31
+ ### Logger Constructor Options
32
+
33
+ | Option | Type | Description |
34
+ | -------------- | -------- | ----------------------- |
35
+ | **level** | `string` | Log level threshold |
36
+ | **json** | `boolean`| Output in JSON format |
37
+ | **timestamp** | `boolean`| Include timestamps |
38
+ | **prefix** | `string` | Prepended label |
39
+ | **transports** | `array` | Where logs are written (with transport-specific options like `path`, `maxSize`, `maxFiles` for file transport) |
40
+ | **customLevels** | `object` | Define custom log levels and their priorities |
41
+ | **customColors** | `object` | Assign colors to custom log levels |
42
+
43
+ ### Log Levels
44
+
45
+ | Level | Method | Use Case |
46
+ |----------|---------------|----------------------------|
47
+ | ๐Ÿ” DEBUG | `logger.debug()` | Detailed debugging info |
48
+ | โœจ INFO | `logger.info()` | General information |
49
+ | โš ๏ธ WARN | `logger.warn()` | Warning messages |
50
+ | โŒ ERROR | `logger.error()` | Error messages |
51
+ | ๐Ÿคซ SILENT | `logger.silent()`| Not output to console |
52
+ | ๐Ÿ“ BORING | `logger.boring()`| Lowest priority messages |
53
+
54
+ ### Transports
55
+
56
+ #### Console Transport
57
+ ```js
58
+ const logger = new Logger({
59
+ transports: [{
60
+ type: 'console',
61
+ options: {
62
+ colorize: true
63
+ }
64
+ }]
65
+ });
66
+ ```
67
+
68
+ #### File Transport
69
+ ```js
70
+ const logger = new Logger({
71
+ transports: [{
72
+ type: 'file',
73
+ options: {
74
+ path: './logs/app.log',
75
+ maxSize: 10485760, // 10MB in bytes
76
+ maxFiles: 5
77
+ }
78
+ }]
79
+ });
80
+ ```
81
+
82
+ ### Methods
83
+
84
+ - `logger.debug(message, metadata?)` - Debug level logging
85
+ - `logger.info(message, metadata?)` - Info level logging
86
+ - `logger.warn(message, metadata?)` - Warning level logging
87
+ - `logger.error(message, metadata?)` - Error level logging
88
+ - `logger.createChild(options)` - Creates a child logger with inherited settings
89
+ - `logger.setLevel(level)` - Change the logger level at runtime
90
+ - `logger.setFormat(format)` - Set the output format to text or json
91
+
92
+ ## Usage Examples
93
+
94
+ ### Basic Usage
95
+ ```js
96
+ import { Logger } from "zario";
97
+
98
+ const logger = new Logger({
99
+ level: "info",
100
+ colorize: true,
101
+ transports: [{ type: "console" }]
102
+ });
103
+
104
+ logger.info("Application started");
105
+ logger.error("Something went wrong", { userId: 123 });
106
+ ```
107
+
108
+ ### JSON Format
109
+ ```js
110
+ const logger = new Logger({ json: true });
111
+ ```
112
+
113
+ ### Custom Levels & Colors
114
+ ```js
115
+ import { Logger } from "zario";
116
+
117
+ const logger = new Logger({
118
+ level: 'info',
119
+ customLevels: {
120
+ 'success': 6, // Higher priority than error (5).
121
+ 'verbose': 1, // Lower priority than debug (2).
122
+ 'critical': 7, // Highest priority.
123
+ },
124
+ customColors: {
125
+ 'success': 'green',
126
+ 'verbose': 'cyan',
127
+ 'critical': 'brightRed',
128
+ },
129
+ transports: [
130
+ { type: 'console' }
131
+ ]
132
+ });
133
+
134
+ // Using custom levels.
135
+ logger.logWithLevel('success', 'This is a success message in green!');
136
+ logger.logWithLevel('verbose', 'This is a verbose message in cyan');
137
+ logger.logWithLevel('critical', 'This is a critical message in bright red');
138
+ ```
139
+
140
+ ### Child Loggers
141
+ ```js
142
+ const main = new Logger({ prefix: "[APP]" });
143
+ const db = main.createChild({ prefix: "[DB]" });
144
+
145
+ main.info("App initialized");
146
+ db.error("Connection timeout");
147
+ ```
148
+
149
+ ### Multiple Transports
150
+ ```js
151
+ const logger = new Logger({
152
+ level: 'info',
153
+ transports: [
154
+ { type: 'console' },
155
+ {
156
+ type: 'file',
157
+ options: { path: './logs/app.log' }
158
+ }
159
+ ]
160
+ });
161
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zario",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A minimal, fast logging library for Node.js.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,7 +17,8 @@
17
17
  "dev": "tsc --watch",
18
18
  "test": "jest",
19
19
  "lint": "eslint . --ext .ts,.js",
20
- "prepublishOnly": "npm run build"
20
+ "prepublishOnly": "npm run build && node -e \"require('fs').copyFileSync('README.npm.md', 'README.md')\"",
21
+ "postpublish": "git checkout HEAD -- README.md"
21
22
  },
22
23
  "repository": {
23
24
  "type": "git",