zario 0.2.0 โ 0.2.5
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/README.md +161 -858
- package/dist/core/Logger.d.ts +10 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/utils/Timerutil.d.ts +8 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,858 +1,161 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
transports: [{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
logger.
|
|
137
|
-
logger.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
<br/>
|
|
163
|
-
|
|
164
|
-

|
|
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
|
-

|
|
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
|
-

|
|
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
|
-

|
|
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
|
-

|
|
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
|
-

|
|
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
|
-
[](../../stargazers)
|
|
813
|
-
[](../../network/members)
|
|
814
|
-
[](../../issues)
|
|
815
|
-
|
|
816
|
-
**Join our growing community!**
|
|
817
|
-
|
|
818
|
-
[๐ฌ Discussions](../../discussions) โข [๐ Issues](../../issues) โข [๐ข Changelog](./CHANGELOG.md)
|
|
819
|
-
|
|
820
|
-
</div>
|
|
821
|
-
|
|
822
|
-
<br/>
|
|
823
|
-
|
|
824
|
-

|
|
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
|
-
[](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/dist/core/Logger.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface LoggerOptions {
|
|
|
11
11
|
timestamp?: boolean;
|
|
12
12
|
context?: Record<string, any>;
|
|
13
13
|
parent?: Logger;
|
|
14
|
-
|
|
14
|
+
asyncMode?: boolean;
|
|
15
15
|
customLevels?: {
|
|
16
16
|
[level: string]: number;
|
|
17
17
|
};
|
|
@@ -31,11 +31,17 @@ export declare class Logger {
|
|
|
31
31
|
prefix: string;
|
|
32
32
|
timestamp: boolean;
|
|
33
33
|
constructor(options?: LoggerOptions);
|
|
34
|
+
private isProductionEnvironment;
|
|
35
|
+
private getDefaultLevel;
|
|
36
|
+
private getDefaultColorizeValue;
|
|
37
|
+
private getDefaultJson;
|
|
38
|
+
private getDefaultTimestamp;
|
|
39
|
+
private getDefaultTransports;
|
|
40
|
+
private getDefaultAsyncMode;
|
|
34
41
|
private initTransports;
|
|
35
42
|
private shouldLog;
|
|
36
43
|
private getLevelPriority;
|
|
37
44
|
private log;
|
|
38
|
-
private logAsync;
|
|
39
45
|
private logAsyncDirect;
|
|
40
46
|
debug(message: string, metadata?: Record<string, any>): void;
|
|
41
47
|
info(message: string, metadata?: Record<string, any>): void;
|
|
@@ -49,9 +55,10 @@ export declare class Logger {
|
|
|
49
55
|
logWithLevel(level: LogLevel, message: string, metadata?: Record<string, any>): void;
|
|
50
56
|
setLevel(level: LogLevel): void;
|
|
51
57
|
setFormat(format: "text" | "json"): void;
|
|
52
|
-
|
|
58
|
+
setAsyncMode(asyncMode: boolean): void;
|
|
53
59
|
addTransport(transport: Transport): void;
|
|
54
60
|
getTimestampSetting(): boolean;
|
|
55
61
|
static get global(): Logger;
|
|
56
62
|
createChild(options?: LoggerOptions): Logger;
|
|
63
|
+
startTimer(name: string): any;
|
|
57
64
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`;
|
|
3
|
-
`;await new Promise((o,
|
|
1
|
+
"use strict";var A=Object.create;var x=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var I=(a,t)=>()=>(a&&(t=a(a=0)),t);var D=(a,t)=>{for(var e in t)x(a,e,{get:t[e],enumerable:!0})},O=(a,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of j(t))!$.call(a,r)&&r!==e&&x(a,r,{get:()=>t[r],enumerable:!(i=M(t,r))||i.enumerable});return a};var P=(a,t,e)=>(e=a!=null?A(E(a)):{},O(t||!a||!a.__esModule?x(e,"default",{value:a,enumerable:!0}):e,a)),w=a=>O(x({},"__esModule",{value:!0}),a);var C={};D(C,{Timer:()=>S});var S,z=I(()=>{"use strict";S=class{constructor(t,e){this.hasEnded=!1;this.name=t,this.logFn=e,this.startTime=Date.now()}end(){if(this.hasEnded)return;let e=Date.now()-this.startTime;this.logFn(`${this.name} took ${e}ms`),this.hasEnded=!0}}});var Y={};D(Y,{ConsoleTransport:()=>d,FileTransport:()=>v,Logger:()=>y,default:()=>N});module.exports=w(Y);var L=class{static format(t,e){if(e==="ISO")return t.toISOString();if(e==="UTC")return t.toUTCString();if(e==="LOCAL")return t.toLocaleString();let i=t.getFullYear(),r=t.getMonth()+1,o=t.getDate(),l=t.getHours(),p=t.getMinutes(),m=t.getSeconds(),u=t.getMilliseconds(),c=[],s=0,g=0;for(;s<e.length;)e[s]==="Y"&&s+3<e.length&&e.slice(s,s+4)==="YYYY"?(c.push(e.substring(g,s)),c.push(i.toString().padStart(4,"0")),s+=4,g=s):e[s]==="M"&&s+1<e.length&&e.slice(s,s+2)==="MM"?(c.push(e.substring(g,s)),c.push(r.toString().padStart(2,"0")),s+=2,g=s):e[s]==="D"&&s+1<e.length&&e.slice(s,s+2)==="DD"?(c.push(e.substring(g,s)),c.push(o.toString().padStart(2,"0")),s+=2,g=s):e[s]==="H"&&s+1<e.length&&e.slice(s,s+2)==="HH"?(c.push(e.substring(g,s)),c.push(l.toString().padStart(2,"0")),s+=2,g=s):e[s]==="m"&&s+1<e.length&&e.slice(s,s+2)==="mm"?(c.push(e.substring(g,s)),c.push(p.toString().padStart(2,"0")),s+=2,g=s):e[s]==="s"&&s+1<e.length&&e.slice(s,s+2)==="ss"?(c.push(e.substring(g,s)),c.push(m.toString().padStart(2,"0")),s+=2,g=s):e[s]==="S"&&s+2<e.length&&e.slice(s,s+3)==="SSS"?(c.push(e.substring(g,s)),c.push(u.toString().padStart(3,"0")),s+=3,g=s):s++;return c.push(e.substring(g)),c.join("")}};var F=class a{static{this.ANSI_COLORS={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",info:"\x1B[32m",warn:"\x1B[33m",error:"\x1B[31m",debug:"\x1B[36m",boring:"\x1B[37m",reset:"\x1B[0m"}}static colorize(t,e){return process.env.FORCE_COLOR!=="0"&&(process.stdout.isTTY||process.env.FORCE_COLOR==="1")?`${a.ANSI_COLORS[e]||a.ANSI_COLORS.reset}${t}${a.ANSI_COLORS.reset}`:t}};var b=class{constructor(t={}){let{colorize:e=!0,json:i=!1,timestampFormat:r="YYYY-MM-DD HH:mm:ss",timestamp:o=!1,customColors:l={}}=t;this.colorize=e,this.json=i,this.timestampFormat=r,this.timestamp=o,this.customColors=l}format(t){return this.json?this.formatAsJson(t):this.formatAsText(t)}formatAsJson(t){let e={level:t.level,message:t.message,...t.metadata};return this.timestamp&&(e.timestamp=t.timestamp.toISOString()),t.prefix&&(e.prefix=t.prefix),JSON.stringify(e)}formatAsText(t){let e=[];if(this.timestamp){let r=L.format(t.timestamp,this.timestampFormat);e.push(`[${r}] `)}t.prefix&&e.push(`${t.prefix} `);let i=t.level.toUpperCase();if(this.colorize){let r=this.customColors[t.level]||t.level;i=F.colorize(i,r)}return e.push(`[${i}] `),e.push(t.message),t.metadata&&e.push(` ${JSON.stringify(t.metadata)}`),e.join("")}setJson(t){this.json=t}isColorized(){return this.colorize}isJson(){return this.json}getTimestampFormat(){return this.timestampFormat}hasTimestamp(){return this.timestamp}getCustomColors(){return{...this.customColors}}};var d=class{constructor(t={}){let{colorize:e=!0}=t;this.colorize=e}write(t,e){let i=e.colorize;this.colorize!==i&&(e.colorize=this.colorize);let r=e.format(t);switch(this.colorize!==i&&(e.colorize=i),t.level){case"error":console.error(r);break;case"warn":console.warn(r);break;default:console.log(r);break}}async writeAsync(t,e){return setImmediate(()=>{this.write(t,e)}),Promise.resolve()}};var n=P(require("fs"),1),h=P(require("path"),1),v=class{constructor(t){let{path:e,maxSize:i=10*1024*1024,maxFiles:r=5}=t;this.filePath=e,this.maxSize=i,this.maxFiles=r;let o=h.dirname(this.filePath);n.existsSync(o)||n.mkdirSync(o,{recursive:!0}),n.existsSync(this.filePath)||n.writeFileSync(this.filePath,"","utf8")}write(t,e){let r=e.format(t)+`
|
|
2
|
+
`;n.appendFileSync(this.filePath,r),this.rotateIfNeeded()}async writeAsync(t,e){let r=e.format(t)+`
|
|
3
|
+
`;await new Promise((o,l)=>{n.appendFile(this.filePath,r,p=>{if(p){l(p);return}o()})}),await this.rotateIfNeededAsync()}rotateIfNeeded(){if(n.existsSync(this.filePath))try{n.statSync(this.filePath).size>=this.maxSize&&this.rotateFiles()}catch(t){console.error("Error checking file size for rotation:",t)}}async rotateIfNeededAsync(){if(n.existsSync(this.filePath))try{n.statSync(this.filePath).size>=this.maxSize&&await this.rotateFilesAsync()}catch(t){console.error("Error during rotation check:",t)}}rotateFiles(){try{let t="";n.existsSync(this.filePath)&&(t=n.readFileSync(this.filePath,"utf8"));let e=this.getRotatedFilePath();n.writeFileSync(e,t,"utf8"),n.writeFileSync(this.filePath,"","utf8"),this.cleanupOldFiles()}catch(t){console.error("Error during file rotation:",t)}}async rotateFilesAsync(){try{let t="";n.existsSync(this.filePath)&&(t=await n.promises.readFile(this.filePath,"utf8"));let e=this.getRotatedFilePath();await n.promises.writeFile(e,t,"utf8"),await n.promises.writeFile(this.filePath,"","utf8"),await this.cleanupOldFilesAsync()}catch(t){console.error("Error during async file rotation:",t)}}getRotatedFilePath(){let t=h.dirname(this.filePath),e=h.basename(this.filePath),i=Date.now();return h.join(t,`${e}.${i}`)}cleanupOldFiles(){try{let t=h.dirname(this.filePath),e=h.basename(this.filePath);try{n.accessSync(t,n.constants.F_OK)}catch{return}let r=n.readdirSync(t).filter(o=>!o||o===e?!1:new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.\\d+$`).test(o)).sort((o,l)=>{let p=parseInt(o.split(".").pop()||"0");return parseInt(l.split(".").pop()||"0")-p});for(let o=this.maxFiles;o<r.length;o++){let l=r[o];if(l){if(l.includes("../")||l.includes("..\\")||l.startsWith(".."))continue;let p=h.join(t,l),m=h.resolve(p),u=h.resolve(t);if(!m.startsWith(u+h.sep)&&m!==u)continue;try{n.unlinkSync(p)}catch(c){console.error(`Failed to delete old log file ${p}:`,c)}}}}catch(t){console.error("Error during cleanup of old files:",t)}}async cleanupOldFilesAsync(){try{let t=h.dirname(this.filePath),e=h.basename(this.filePath);try{await n.promises.access(t,n.constants.F_OK)}catch{return}let r=(await n.promises.readdir(t)).filter(l=>!l||l===e?!1:new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.\\d+$`).test(l)).sort((l,p)=>{let m=parseInt(l.split(".").pop()||"0");return parseInt(p.split(".").pop()||"0")-m}),o=[];for(let l=this.maxFiles;l<r.length;l++){let p=r[l];if(p){if(p.includes("../")||p.includes("..\\")||p.startsWith(".."))continue;let m=h.join(t,p),u=h.resolve(m),c=h.resolve(t);if(!u.startsWith(c+h.sep)&&u!==c)continue;o.push(n.promises.access(m,n.constants.F_OK).then(()=>n.promises.unlink(m)).catch(s=>{s.code!=="ENOENT"&&console.error(`Failed to delete old log file ${m}:`,s)}))}}await Promise.all(o)}catch(t){console.error("Error during async cleanup of old files:",t)}}};var y=class a{constructor(t={}){this.transports=[];let{level:e,colorize:i,json:r,transports:o=[],timestampFormat:l="YYYY-MM-DD HH:mm:ss",prefix:p,timestamp:m,context:u={},parent:c,asyncMode:s,customLevels:g={},customColors:T={}}=t;if(this.parent=c,this.context={...u},this.customLevels=g,this.asyncMode=!1,this.parent){this.level=e??this.parent.level,this.prefix=p??this.parent.prefix,this.timestamp=m??this.parent.timestamp,this.asyncMode=s??this.parent.asyncMode,this.transports=o&&o.length>0?this.initTransports(o,this.getDefaultColorizeValue(i)):this.parent.transports;let f={...this.parent.formatter.getCustomColors(),...T};this.formatter=new b({colorize:this.getDefaultColorizeValue(i)??this.parent.formatter.isColorized(),json:r??this.parent.formatter.isJson(),timestampFormat:l??this.parent.formatter.getTimestampFormat(),timestamp:m??this.parent.formatter.hasTimestamp(),customColors:f}),this.context={...this.parent.context,...this.context},this.customLevels={...this.parent.customLevels,...g}}else{let f=this.isProductionEnvironment();this.level=e??this.getDefaultLevel(f),this.prefix=p??"",this.timestamp=m??this.getDefaultTimestamp(f);let R=o&&o.length>0?o:this.getDefaultTransports(f);this.asyncMode=s??this.getDefaultAsyncMode(f),this.transports=this.initTransports(R,this.getDefaultColorizeValue(i)),this.formatter=new b({colorize:this.getDefaultColorizeValue(i),json:r??this.getDefaultJson(f),timestampFormat:l,timestamp:this.getDefaultTimestamp(f),customColors:T})}a._global||(a._global=this)}isProductionEnvironment(){let t=process.env.NODE_ENV?.toLowerCase();return t==="production"||t==="prod"}getDefaultLevel(t){return t?"warn":"debug"}getDefaultColorizeValue(t){return t!==void 0?t:!this.isProductionEnvironment()}getDefaultJson(t){return t}getDefaultTimestamp(t){return!0}getDefaultTransports(t){return t?[{type:"console"},{type:"file",options:{path:"./logs/app.log"}}]:[{type:"console"}]}getDefaultAsyncMode(t){return t}initTransports(t,e){let i=[];for(let r of t)if(r.type==="console"){let o=new d({colorize:r.options?.colorize??e});i.push(o)}else if(r.type==="file"){if(r.options?.path){let o={path:r.options.path};r.options.maxSize!==void 0&&(o.maxSize=r.options.maxSize),r.options.maxFiles!==void 0&&(o.maxFiles=r.options.maxFiles);let l=new v(o);i.push(l)}}else r.type==="custom"&&r.instance&&i.push(r.instance);return i}shouldLog(t){let e=this.getLevelPriority(this.level);return this.getLevelPriority(t)>=e}getLevelPriority(t){switch(t){case"silent":return 0;case"boring":return 1;case"debug":return 2;case"info":return 3;case"warn":return 4;case"error":return 5;default:if(this.customLevels&&t in this.customLevels){let e=this.customLevels[t];return e!==void 0?e:999}return 999}}log(t,e,i){if(this.shouldLog(t)&&t!=="silent")if(this.asyncMode)this.logAsyncDirect(t,e,i);else{let r=new Date,o;this.context&&Object.keys(this.context).length>0?i?o={...this.context,...i}:o=this.context:i&&(o=i);let l={level:t,message:e,timestamp:r,metadata:o&&Object.keys(o).length>0?o:void 0,prefix:this.prefix};for(let p of this.transports)p.write(l,this.formatter)}}logAsyncDirect(t,e,i){if(!this.shouldLog(t)||t==="silent")return;let r=new Date,o;this.context&&Object.keys(this.context).length>0?i?o={...this.context,...i}:o=this.context:i&&(o=i);let l={level:t,message:e,timestamp:r,metadata:o&&Object.keys(o).length>0?o:void 0,prefix:this.prefix};for(let p of this.transports)p.writeAsync?p.writeAsync(l,this.formatter).catch(m=>{console.error("Error during async logging:",m)}):setImmediate(()=>{p.write(l,this.formatter)})}debug(t,e){this.log("debug",t,e)}info(t,e){this.log("info",t,e)}warn(t,e){this.log("warn",t,e)}error(t,e){this.log("error",t,e)}silent(t,e){this.log("silent",t,e)}boring(t,e){this.log("boring",t,e)}logWithLevel(t,e,i){this.log(t,e,i)}setLevel(t){this.level=t}setFormat(t){this.formatter.setJson(t==="json")}setAsyncMode(t){this.asyncMode=t}addTransport(t){this.transports.push(t)}getTimestampSetting(){return this.timestamp}static get global(){return a._global||(a._global=new a),a._global}createChild(t={}){return new a({...t,parent:this})}startTimer(t){let{Timer:e}=(z(),w(C));return new e(t,i=>this.info(i))}};var N=y;0&&(module.exports={ConsoleTransport,FileTransport,Logger});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`;
|
|
3
|
-
`;await new Promise((
|
|
1
|
+
var F=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var R=(l,t)=>()=>(l&&(t=l(l=0)),t);var A=(l,t)=>{for(var e in t)F(l,e,{get:t[e],enumerable:!0})},M=(l,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of C(t))!z.call(l,r)&&r!==e&&F(l,r,{get:()=>t[r],enumerable:!(i=w(t,r))||i.enumerable});return l};var j=l=>M(F({},"__esModule",{value:!0}),l);var D={};A(D,{Timer:()=>S});var S,O=R(()=>{"use strict";S=class{constructor(t,e){this.hasEnded=!1;this.name=t,this.logFn=e,this.startTime=Date.now()}end(){if(this.hasEnded)return;let e=Date.now()-this.startTime;this.logFn(`${this.name} took ${e}ms`),this.hasEnded=!0}}});var y=class{static format(t,e){if(e==="ISO")return t.toISOString();if(e==="UTC")return t.toUTCString();if(e==="LOCAL")return t.toLocaleString();let i=t.getFullYear(),r=t.getMonth()+1,o=t.getDate(),a=t.getHours(),p=t.getMinutes(),m=t.getSeconds(),u=t.getMilliseconds(),c=[],s=0,g=0;for(;s<e.length;)e[s]==="Y"&&s+3<e.length&&e.slice(s,s+4)==="YYYY"?(c.push(e.substring(g,s)),c.push(i.toString().padStart(4,"0")),s+=4,g=s):e[s]==="M"&&s+1<e.length&&e.slice(s,s+2)==="MM"?(c.push(e.substring(g,s)),c.push(r.toString().padStart(2,"0")),s+=2,g=s):e[s]==="D"&&s+1<e.length&&e.slice(s,s+2)==="DD"?(c.push(e.substring(g,s)),c.push(o.toString().padStart(2,"0")),s+=2,g=s):e[s]==="H"&&s+1<e.length&&e.slice(s,s+2)==="HH"?(c.push(e.substring(g,s)),c.push(a.toString().padStart(2,"0")),s+=2,g=s):e[s]==="m"&&s+1<e.length&&e.slice(s,s+2)==="mm"?(c.push(e.substring(g,s)),c.push(p.toString().padStart(2,"0")),s+=2,g=s):e[s]==="s"&&s+1<e.length&&e.slice(s,s+2)==="ss"?(c.push(e.substring(g,s)),c.push(m.toString().padStart(2,"0")),s+=2,g=s):e[s]==="S"&&s+2<e.length&&e.slice(s,s+3)==="SSS"?(c.push(e.substring(g,s)),c.push(u.toString().padStart(3,"0")),s+=3,g=s):s++;return c.push(e.substring(g)),c.join("")}};var x=class l{static{this.ANSI_COLORS={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",info:"\x1B[32m",warn:"\x1B[33m",error:"\x1B[31m",debug:"\x1B[36m",boring:"\x1B[37m",reset:"\x1B[0m"}}static colorize(t,e){return process.env.FORCE_COLOR!=="0"&&(process.stdout.isTTY||process.env.FORCE_COLOR==="1")?`${l.ANSI_COLORS[e]||l.ANSI_COLORS.reset}${t}${l.ANSI_COLORS.reset}`:t}};var d=class{constructor(t={}){let{colorize:e=!0,json:i=!1,timestampFormat:r="YYYY-MM-DD HH:mm:ss",timestamp:o=!1,customColors:a={}}=t;this.colorize=e,this.json=i,this.timestampFormat=r,this.timestamp=o,this.customColors=a}format(t){return this.json?this.formatAsJson(t):this.formatAsText(t)}formatAsJson(t){let e={level:t.level,message:t.message,...t.metadata};return this.timestamp&&(e.timestamp=t.timestamp.toISOString()),t.prefix&&(e.prefix=t.prefix),JSON.stringify(e)}formatAsText(t){let e=[];if(this.timestamp){let r=y.format(t.timestamp,this.timestampFormat);e.push(`[${r}] `)}t.prefix&&e.push(`${t.prefix} `);let i=t.level.toUpperCase();if(this.colorize){let r=this.customColors[t.level]||t.level;i=x.colorize(i,r)}return e.push(`[${i}] `),e.push(t.message),t.metadata&&e.push(` ${JSON.stringify(t.metadata)}`),e.join("")}setJson(t){this.json=t}isColorized(){return this.colorize}isJson(){return this.json}getTimestampFormat(){return this.timestampFormat}hasTimestamp(){return this.timestamp}getCustomColors(){return{...this.customColors}}};var v=class{constructor(t={}){let{colorize:e=!0}=t;this.colorize=e}write(t,e){let i=e.colorize;this.colorize!==i&&(e.colorize=this.colorize);let r=e.format(t);switch(this.colorize!==i&&(e.colorize=i),t.level){case"error":console.error(r);break;case"warn":console.warn(r);break;default:console.log(r);break}}async writeAsync(t,e){return setImmediate(()=>{this.write(t,e)}),Promise.resolve()}};import*as n from"fs";import*as h from"path";var b=class{constructor(t){let{path:e,maxSize:i=10*1024*1024,maxFiles:r=5}=t;this.filePath=e,this.maxSize=i,this.maxFiles=r;let o=h.dirname(this.filePath);n.existsSync(o)||n.mkdirSync(o,{recursive:!0}),n.existsSync(this.filePath)||n.writeFileSync(this.filePath,"","utf8")}write(t,e){let r=e.format(t)+`
|
|
2
|
+
`;n.appendFileSync(this.filePath,r),this.rotateIfNeeded()}async writeAsync(t,e){let r=e.format(t)+`
|
|
3
|
+
`;await new Promise((o,a)=>{n.appendFile(this.filePath,r,p=>{if(p){a(p);return}o()})}),await this.rotateIfNeededAsync()}rotateIfNeeded(){if(n.existsSync(this.filePath))try{n.statSync(this.filePath).size>=this.maxSize&&this.rotateFiles()}catch(t){console.error("Error checking file size for rotation:",t)}}async rotateIfNeededAsync(){if(n.existsSync(this.filePath))try{n.statSync(this.filePath).size>=this.maxSize&&await this.rotateFilesAsync()}catch(t){console.error("Error during rotation check:",t)}}rotateFiles(){try{let t="";n.existsSync(this.filePath)&&(t=n.readFileSync(this.filePath,"utf8"));let e=this.getRotatedFilePath();n.writeFileSync(e,t,"utf8"),n.writeFileSync(this.filePath,"","utf8"),this.cleanupOldFiles()}catch(t){console.error("Error during file rotation:",t)}}async rotateFilesAsync(){try{let t="";n.existsSync(this.filePath)&&(t=await n.promises.readFile(this.filePath,"utf8"));let e=this.getRotatedFilePath();await n.promises.writeFile(e,t,"utf8"),await n.promises.writeFile(this.filePath,"","utf8"),await this.cleanupOldFilesAsync()}catch(t){console.error("Error during async file rotation:",t)}}getRotatedFilePath(){let t=h.dirname(this.filePath),e=h.basename(this.filePath),i=Date.now();return h.join(t,`${e}.${i}`)}cleanupOldFiles(){try{let t=h.dirname(this.filePath),e=h.basename(this.filePath);try{n.accessSync(t,n.constants.F_OK)}catch{return}let r=n.readdirSync(t).filter(o=>!o||o===e?!1:new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.\\d+$`).test(o)).sort((o,a)=>{let p=parseInt(o.split(".").pop()||"0");return parseInt(a.split(".").pop()||"0")-p});for(let o=this.maxFiles;o<r.length;o++){let a=r[o];if(a){if(a.includes("../")||a.includes("..\\")||a.startsWith(".."))continue;let p=h.join(t,a),m=h.resolve(p),u=h.resolve(t);if(!m.startsWith(u+h.sep)&&m!==u)continue;try{n.unlinkSync(p)}catch(c){console.error(`Failed to delete old log file ${p}:`,c)}}}}catch(t){console.error("Error during cleanup of old files:",t)}}async cleanupOldFilesAsync(){try{let t=h.dirname(this.filePath),e=h.basename(this.filePath);try{await n.promises.access(t,n.constants.F_OK)}catch{return}let r=(await n.promises.readdir(t)).filter(a=>!a||a===e?!1:new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.\\d+$`).test(a)).sort((a,p)=>{let m=parseInt(a.split(".").pop()||"0");return parseInt(p.split(".").pop()||"0")-m}),o=[];for(let a=this.maxFiles;a<r.length;a++){let p=r[a];if(p){if(p.includes("../")||p.includes("..\\")||p.startsWith(".."))continue;let m=h.join(t,p),u=h.resolve(m),c=h.resolve(t);if(!u.startsWith(c+h.sep)&&u!==c)continue;o.push(n.promises.access(m,n.constants.F_OK).then(()=>n.promises.unlink(m)).catch(s=>{s.code!=="ENOENT"&&console.error(`Failed to delete old log file ${m}:`,s)}))}}await Promise.all(o)}catch(t){console.error("Error during async cleanup of old files:",t)}}};var L=class l{constructor(t={}){this.transports=[];let{level:e,colorize:i,json:r,transports:o=[],timestampFormat:a="YYYY-MM-DD HH:mm:ss",prefix:p,timestamp:m,context:u={},parent:c,asyncMode:s,customLevels:g={},customColors:T={}}=t;if(this.parent=c,this.context={...u},this.customLevels=g,this.asyncMode=!1,this.parent){this.level=e??this.parent.level,this.prefix=p??this.parent.prefix,this.timestamp=m??this.parent.timestamp,this.asyncMode=s??this.parent.asyncMode,this.transports=o&&o.length>0?this.initTransports(o,this.getDefaultColorizeValue(i)):this.parent.transports;let f={...this.parent.formatter.getCustomColors(),...T};this.formatter=new d({colorize:this.getDefaultColorizeValue(i)??this.parent.formatter.isColorized(),json:r??this.parent.formatter.isJson(),timestampFormat:a??this.parent.formatter.getTimestampFormat(),timestamp:m??this.parent.formatter.hasTimestamp(),customColors:f}),this.context={...this.parent.context,...this.context},this.customLevels={...this.parent.customLevels,...g}}else{let f=this.isProductionEnvironment();this.level=e??this.getDefaultLevel(f),this.prefix=p??"",this.timestamp=m??this.getDefaultTimestamp(f);let P=o&&o.length>0?o:this.getDefaultTransports(f);this.asyncMode=s??this.getDefaultAsyncMode(f),this.transports=this.initTransports(P,this.getDefaultColorizeValue(i)),this.formatter=new d({colorize:this.getDefaultColorizeValue(i),json:r??this.getDefaultJson(f),timestampFormat:a,timestamp:this.getDefaultTimestamp(f),customColors:T})}l._global||(l._global=this)}isProductionEnvironment(){let t=process.env.NODE_ENV?.toLowerCase();return t==="production"||t==="prod"}getDefaultLevel(t){return t?"warn":"debug"}getDefaultColorizeValue(t){return t!==void 0?t:!this.isProductionEnvironment()}getDefaultJson(t){return t}getDefaultTimestamp(t){return!0}getDefaultTransports(t){return t?[{type:"console"},{type:"file",options:{path:"./logs/app.log"}}]:[{type:"console"}]}getDefaultAsyncMode(t){return t}initTransports(t,e){let i=[];for(let r of t)if(r.type==="console"){let o=new v({colorize:r.options?.colorize??e});i.push(o)}else if(r.type==="file"){if(r.options?.path){let o={path:r.options.path};r.options.maxSize!==void 0&&(o.maxSize=r.options.maxSize),r.options.maxFiles!==void 0&&(o.maxFiles=r.options.maxFiles);let a=new b(o);i.push(a)}}else r.type==="custom"&&r.instance&&i.push(r.instance);return i}shouldLog(t){let e=this.getLevelPriority(this.level);return this.getLevelPriority(t)>=e}getLevelPriority(t){switch(t){case"silent":return 0;case"boring":return 1;case"debug":return 2;case"info":return 3;case"warn":return 4;case"error":return 5;default:if(this.customLevels&&t in this.customLevels){let e=this.customLevels[t];return e!==void 0?e:999}return 999}}log(t,e,i){if(this.shouldLog(t)&&t!=="silent")if(this.asyncMode)this.logAsyncDirect(t,e,i);else{let r=new Date,o;this.context&&Object.keys(this.context).length>0?i?o={...this.context,...i}:o=this.context:i&&(o=i);let a={level:t,message:e,timestamp:r,metadata:o&&Object.keys(o).length>0?o:void 0,prefix:this.prefix};for(let p of this.transports)p.write(a,this.formatter)}}logAsyncDirect(t,e,i){if(!this.shouldLog(t)||t==="silent")return;let r=new Date,o;this.context&&Object.keys(this.context).length>0?i?o={...this.context,...i}:o=this.context:i&&(o=i);let a={level:t,message:e,timestamp:r,metadata:o&&Object.keys(o).length>0?o:void 0,prefix:this.prefix};for(let p of this.transports)p.writeAsync?p.writeAsync(a,this.formatter).catch(m=>{console.error("Error during async logging:",m)}):setImmediate(()=>{p.write(a,this.formatter)})}debug(t,e){this.log("debug",t,e)}info(t,e){this.log("info",t,e)}warn(t,e){this.log("warn",t,e)}error(t,e){this.log("error",t,e)}silent(t,e){this.log("silent",t,e)}boring(t,e){this.log("boring",t,e)}logWithLevel(t,e,i){this.log(t,e,i)}setLevel(t){this.level=t}setFormat(t){this.formatter.setJson(t==="json")}setAsyncMode(t){this.asyncMode=t}addTransport(t){this.transports.push(t)}getTimestampSetting(){return this.timestamp}static get global(){return l._global||(l._global=new l),l._global}createChild(t={}){return new l({...t,parent:this})}startTimer(t){let{Timer:e}=(O(),j(D));return new e(t,i=>this.info(i))}};var et=L;export{v as ConsoleTransport,b as FileTransport,L as Logger,et as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zario",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
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",
|
|
@@ -50,7 +51,6 @@
|
|
|
50
51
|
},
|
|
51
52
|
"files": [
|
|
52
53
|
"dist/**/*",
|
|
53
|
-
"README.md"
|
|
54
|
-
"README.npm.md"
|
|
54
|
+
"README.md"
|
|
55
55
|
]
|
|
56
56
|
}
|