@abdokouta/react-logger 1.0.0 → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +38 -41
- package/config/logger.config.ts +19 -20
- package/dist/index.d.cts +35 -21
- package/dist/index.d.ts +35 -21
- package/dist/index.js +32 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +53 -30
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Refine
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @abdokouta/logger
|
|
2
2
|
|
|
3
|
-
Laravel-inspired logging system for Refine with multiple channels, transporters,
|
|
3
|
+
Laravel-inspired logging system for Refine with multiple channels, transporters,
|
|
4
|
+
and formatters.
|
|
4
5
|
|
|
5
6
|
## Features
|
|
6
7
|
|
|
@@ -68,13 +69,11 @@ import { LoggerService } from '@abdokouta/logger';
|
|
|
68
69
|
|
|
69
70
|
@Injectable()
|
|
70
71
|
export class UserService {
|
|
71
|
-
constructor(
|
|
72
|
-
@Inject(LoggerService) private logger: LoggerService
|
|
73
|
-
) {}
|
|
72
|
+
constructor(@Inject(LoggerService) private logger: LoggerService) {}
|
|
74
73
|
|
|
75
74
|
async createUser(data: UserData) {
|
|
76
75
|
this.logger.info('Creating user', { email: data.email });
|
|
77
|
-
|
|
76
|
+
|
|
78
77
|
try {
|
|
79
78
|
const user = await this.db.users.create(data);
|
|
80
79
|
this.logger.info('User created', { userId: user.id });
|
|
@@ -117,7 +116,7 @@ function MyComponent() {
|
|
|
117
116
|
interface LoggerModuleOptions {
|
|
118
117
|
/** Default channel name */
|
|
119
118
|
default: string;
|
|
120
|
-
|
|
119
|
+
|
|
121
120
|
/** Channel configurations */
|
|
122
121
|
channels: Record<string, LoggerConfig>;
|
|
123
122
|
}
|
|
@@ -125,7 +124,7 @@ interface LoggerModuleOptions {
|
|
|
125
124
|
interface LoggerConfig {
|
|
126
125
|
/** Transporters for this channel */
|
|
127
126
|
transporters?: TransporterInterface[];
|
|
128
|
-
|
|
127
|
+
|
|
129
128
|
/** Initial shared context */
|
|
130
129
|
context?: Record<string, unknown>;
|
|
131
130
|
}
|
|
@@ -272,7 +271,7 @@ Outputs to browser console with colors and emoji.
|
|
|
272
271
|
new ConsoleTransporter({
|
|
273
272
|
formatter: new PrettyFormatter(), // default
|
|
274
273
|
level: LogLevel.Debug, // minimum level
|
|
275
|
-
})
|
|
274
|
+
});
|
|
276
275
|
```
|
|
277
276
|
|
|
278
277
|
### StorageTransporter
|
|
@@ -285,7 +284,7 @@ new StorageTransporter({
|
|
|
285
284
|
maxEntries: 100, // max entries to keep
|
|
286
285
|
formatter: new JsonFormatter(), // default
|
|
287
286
|
level: LogLevel.Debug, // minimum level
|
|
288
|
-
})
|
|
287
|
+
});
|
|
289
288
|
```
|
|
290
289
|
|
|
291
290
|
### SilentTransporter
|
|
@@ -293,7 +292,7 @@ new StorageTransporter({
|
|
|
293
292
|
No-op transporter (discards all logs).
|
|
294
293
|
|
|
295
294
|
```typescript
|
|
296
|
-
new SilentTransporter()
|
|
295
|
+
new SilentTransporter();
|
|
297
296
|
```
|
|
298
297
|
|
|
299
298
|
## Formatters
|
|
@@ -303,7 +302,7 @@ new SilentTransporter()
|
|
|
303
302
|
Colorful output with emoji (default for console).
|
|
304
303
|
|
|
305
304
|
```typescript
|
|
306
|
-
new PrettyFormatter()
|
|
305
|
+
new PrettyFormatter();
|
|
307
306
|
// Output: 🐛 [DEBUG] [14:30:00.000] Hello world {userId: 42}
|
|
308
307
|
```
|
|
309
308
|
|
|
@@ -312,7 +311,7 @@ new PrettyFormatter()
|
|
|
312
311
|
JSON output (default for storage).
|
|
313
312
|
|
|
314
313
|
```typescript
|
|
315
|
-
new JsonFormatter()
|
|
314
|
+
new JsonFormatter();
|
|
316
315
|
// Output: {"level":"info","message":"Hello","timestamp":"...","context":{}}
|
|
317
316
|
```
|
|
318
317
|
|
|
@@ -321,7 +320,7 @@ new JsonFormatter()
|
|
|
321
320
|
Plain text output.
|
|
322
321
|
|
|
323
322
|
```typescript
|
|
324
|
-
new SimpleFormatter()
|
|
323
|
+
new SimpleFormatter();
|
|
325
324
|
// Output: [DEBUG] [2026-03-28T14:30:00.000Z] Hello world {userId: 42}
|
|
326
325
|
```
|
|
327
326
|
|
|
@@ -336,14 +335,14 @@ import { useLogger } from '@abdokouta/logger';
|
|
|
336
335
|
|
|
337
336
|
function MyComponent() {
|
|
338
337
|
const logger = useLogger();
|
|
339
|
-
|
|
338
|
+
|
|
340
339
|
// Use default channel
|
|
341
340
|
logger.info('Component rendered');
|
|
342
|
-
|
|
341
|
+
|
|
343
342
|
// Use specific channel
|
|
344
343
|
const errorLogger = useLogger('errors');
|
|
345
344
|
errorLogger.error('Something went wrong');
|
|
346
|
-
|
|
345
|
+
|
|
347
346
|
return <div>Hello</div>;
|
|
348
347
|
}
|
|
349
348
|
```
|
|
@@ -358,14 +357,14 @@ import { useLoggerContext, useLogger } from '@abdokouta/logger';
|
|
|
358
357
|
function UserProfile({ userId }: { userId: string }) {
|
|
359
358
|
// Add userId to all logs in this component
|
|
360
359
|
useLoggerContext({ userId, component: 'UserProfile' });
|
|
361
|
-
|
|
360
|
+
|
|
362
361
|
const logger = useLogger();
|
|
363
|
-
|
|
362
|
+
|
|
364
363
|
const handleUpdate = () => {
|
|
365
364
|
// This log will include { userId, component: 'UserProfile' }
|
|
366
365
|
logger.info('Updating profile');
|
|
367
366
|
};
|
|
368
|
-
|
|
367
|
+
|
|
369
368
|
return <button onClick={handleUpdate}>Update</button>;
|
|
370
369
|
}
|
|
371
370
|
```
|
|
@@ -377,16 +376,14 @@ function UserProfile({ userId }: { userId: string }) {
|
|
|
377
376
|
```typescript
|
|
378
377
|
@Injectable()
|
|
379
378
|
export class AuthService {
|
|
380
|
-
constructor(
|
|
381
|
-
@Inject(LoggerService) private logger: LoggerService
|
|
382
|
-
) {}
|
|
379
|
+
constructor(@Inject(LoggerService) private logger: LoggerService) {}
|
|
383
380
|
|
|
384
381
|
async login(email: string, password: string) {
|
|
385
382
|
// Add request context
|
|
386
383
|
this.logger.withContext({ email, action: 'login' });
|
|
387
|
-
|
|
384
|
+
|
|
388
385
|
this.logger.info('Login attempt');
|
|
389
|
-
|
|
386
|
+
|
|
390
387
|
try {
|
|
391
388
|
const user = await this.authenticate(email, password);
|
|
392
389
|
this.logger.info('Login successful', { userId: user.id });
|
|
@@ -407,13 +404,11 @@ export class AuthService {
|
|
|
407
404
|
```typescript
|
|
408
405
|
@Injectable()
|
|
409
406
|
export class PaymentService {
|
|
410
|
-
constructor(
|
|
411
|
-
@Inject(LoggerService) private logger: LoggerService
|
|
412
|
-
) {}
|
|
407
|
+
constructor(@Inject(LoggerService) private logger: LoggerService) {}
|
|
413
408
|
|
|
414
409
|
async processPayment(orderId: string, amount: number) {
|
|
415
410
|
const errorLogger = this.logger.channel('errors');
|
|
416
|
-
|
|
411
|
+
|
|
417
412
|
try {
|
|
418
413
|
const result = await this.chargeCard(orderId, amount);
|
|
419
414
|
this.logger.info('Payment processed', { orderId, amount });
|
|
@@ -436,25 +431,23 @@ export class PaymentService {
|
|
|
436
431
|
```typescript
|
|
437
432
|
@Injectable()
|
|
438
433
|
export class UserService {
|
|
439
|
-
constructor(
|
|
440
|
-
@Inject(LoggerService) private logger: LoggerService
|
|
441
|
-
) {}
|
|
434
|
+
constructor(@Inject(LoggerService) private logger: LoggerService) {}
|
|
442
435
|
|
|
443
436
|
async updateUser(userId: string, data: Partial<User>) {
|
|
444
437
|
const auditLogger = this.logger.channel('audit');
|
|
445
|
-
|
|
438
|
+
|
|
446
439
|
auditLogger.info('User update started', {
|
|
447
440
|
userId,
|
|
448
441
|
changes: Object.keys(data),
|
|
449
442
|
});
|
|
450
|
-
|
|
443
|
+
|
|
451
444
|
const user = await this.db.users.update(userId, data);
|
|
452
|
-
|
|
445
|
+
|
|
453
446
|
auditLogger.info('User update completed', {
|
|
454
447
|
userId,
|
|
455
448
|
changes: data,
|
|
456
449
|
});
|
|
457
|
-
|
|
450
|
+
|
|
458
451
|
return user;
|
|
459
452
|
}
|
|
460
453
|
}
|
|
@@ -467,7 +460,7 @@ import { defineConfig, consolePreset, silentPreset } from '@abdokouta/logger';
|
|
|
467
460
|
|
|
468
461
|
export const getLoggerConfig = () => {
|
|
469
462
|
const env = process.env.NODE_ENV || 'development';
|
|
470
|
-
|
|
463
|
+
|
|
471
464
|
if (env === 'production') {
|
|
472
465
|
return defineConfig({
|
|
473
466
|
default: 'console',
|
|
@@ -484,11 +477,11 @@ export const getLoggerConfig = () => {
|
|
|
484
477
|
},
|
|
485
478
|
});
|
|
486
479
|
}
|
|
487
|
-
|
|
480
|
+
|
|
488
481
|
if (env === 'test') {
|
|
489
482
|
return defineConfig(silentPreset);
|
|
490
483
|
}
|
|
491
|
-
|
|
484
|
+
|
|
492
485
|
// Development
|
|
493
486
|
return defineConfig({
|
|
494
487
|
...consolePreset,
|
|
@@ -505,7 +498,8 @@ export const getLoggerConfig = () => {
|
|
|
505
498
|
|
|
506
499
|
## Best Practices
|
|
507
500
|
|
|
508
|
-
1. **Use Appropriate Log Levels**: Debug for development, Info for important
|
|
501
|
+
1. **Use Appropriate Log Levels**: Debug for development, Info for important
|
|
502
|
+
events, Warn for issues, Error for failures, Fatal for critical errors
|
|
509
503
|
2. **Add Context**: Include relevant data to make logs useful
|
|
510
504
|
3. **Use Channels**: Separate concerns (console, storage, errors, audit)
|
|
511
505
|
4. **Clean Up Context**: Remove sensitive data after logging
|
|
@@ -533,11 +527,13 @@ import type {
|
|
|
533
527
|
## Browser Compatibility
|
|
534
528
|
|
|
535
529
|
This package works in all modern browsers that support:
|
|
530
|
+
|
|
536
531
|
- localStorage API
|
|
537
532
|
- console API
|
|
538
533
|
- ES2020 features
|
|
539
534
|
|
|
540
|
-
No polyfills required for modern browsers (Chrome 80+, Firefox 75+, Safari
|
|
535
|
+
No polyfills required for modern browsers (Chrome 80+, Firefox 75+, Safari
|
|
536
|
+
13.1+, Edge 80+).
|
|
541
537
|
|
|
542
538
|
## License
|
|
543
539
|
|
|
@@ -545,7 +541,8 @@ MIT
|
|
|
545
541
|
|
|
546
542
|
## Contributing
|
|
547
543
|
|
|
548
|
-
Contributions are welcome! Please read our contributing guidelines before
|
|
544
|
+
Contributions are welcome! Please read our contributing guidelines before
|
|
545
|
+
submitting PRs.
|
|
549
546
|
|
|
550
547
|
## Support
|
|
551
548
|
|
package/config/logger.config.ts
CHANGED
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
+
defineConfig,
|
|
18
19
|
LogLevel,
|
|
19
20
|
SilentTransporter,
|
|
20
21
|
ConsoleTransporter,
|
|
21
22
|
StorageTransporter,
|
|
22
|
-
} from
|
|
23
|
-
import type { LoggerModuleOptions } from "@abdokouta/logger";
|
|
23
|
+
} from '@abdokouta/logger';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Logger configuration
|
|
@@ -35,7 +35,7 @@ import type { LoggerModuleOptions } from "@abdokouta/logger";
|
|
|
35
35
|
* - NODE_ENV: Environment (development/production/test)
|
|
36
36
|
* - LOG_STORAGE_MAX_ENTRIES: Max storage entries (default: 500)
|
|
37
37
|
*/
|
|
38
|
-
const loggerConfig
|
|
38
|
+
const loggerConfig = defineConfig({
|
|
39
39
|
/*
|
|
40
40
|
|--------------------------------------------------------------------------
|
|
41
41
|
| Default Log Channel
|
|
@@ -46,7 +46,7 @@ const loggerConfig: LoggerModuleOptions = {
|
|
|
46
46
|
| one of the channels defined in the "channels" configuration array.
|
|
47
47
|
|
|
|
48
48
|
*/
|
|
49
|
-
default: process.env.LOG_CHANNEL ||
|
|
49
|
+
default: process.env.LOG_CHANNEL || 'console',
|
|
50
50
|
|
|
51
51
|
/*
|
|
52
52
|
|--------------------------------------------------------------------------
|
|
@@ -66,13 +66,12 @@ const loggerConfig: LoggerModuleOptions = {
|
|
|
66
66
|
console: {
|
|
67
67
|
transporters: [
|
|
68
68
|
new ConsoleTransporter({
|
|
69
|
-
level:
|
|
70
|
-
(process.env.LOG_LEVEL as unknown as LogLevel) || LogLevel.Debug,
|
|
69
|
+
level: (process.env.LOG_LEVEL as unknown as LogLevel) || LogLevel.Debug,
|
|
71
70
|
}),
|
|
72
71
|
],
|
|
73
72
|
context: {
|
|
74
|
-
app: process.env.APP_NAME ||
|
|
75
|
-
env: process.env.NODE_ENV ||
|
|
73
|
+
app: process.env.APP_NAME || 'refine-app',
|
|
74
|
+
env: process.env.NODE_ENV || 'development',
|
|
76
75
|
},
|
|
77
76
|
},
|
|
78
77
|
|
|
@@ -85,12 +84,12 @@ const loggerConfig: LoggerModuleOptions = {
|
|
|
85
84
|
storage: {
|
|
86
85
|
transporters: [
|
|
87
86
|
new StorageTransporter({
|
|
88
|
-
key:
|
|
87
|
+
key: 'app-logs',
|
|
89
88
|
maxEntries: Number(process.env.LOG_STORAGE_MAX_ENTRIES) || 500,
|
|
90
89
|
}),
|
|
91
90
|
],
|
|
92
91
|
context: {
|
|
93
|
-
app: process.env.APP_NAME ||
|
|
92
|
+
app: process.env.APP_NAME || 'refine-app',
|
|
94
93
|
},
|
|
95
94
|
},
|
|
96
95
|
|
|
@@ -106,13 +105,13 @@ const loggerConfig: LoggerModuleOptions = {
|
|
|
106
105
|
level: LogLevel.Info,
|
|
107
106
|
}),
|
|
108
107
|
new StorageTransporter({
|
|
109
|
-
key:
|
|
108
|
+
key: 'app-logs',
|
|
110
109
|
maxEntries: 1000,
|
|
111
110
|
}),
|
|
112
111
|
],
|
|
113
112
|
context: {
|
|
114
|
-
app: process.env.APP_NAME ||
|
|
115
|
-
env: process.env.NODE_ENV ||
|
|
113
|
+
app: process.env.APP_NAME || 'refine-app',
|
|
114
|
+
env: process.env.NODE_ENV || 'production',
|
|
116
115
|
},
|
|
117
116
|
},
|
|
118
117
|
|
|
@@ -128,13 +127,13 @@ const loggerConfig: LoggerModuleOptions = {
|
|
|
128
127
|
level: LogLevel.Error,
|
|
129
128
|
}),
|
|
130
129
|
new StorageTransporter({
|
|
131
|
-
key:
|
|
130
|
+
key: 'error-logs',
|
|
132
131
|
maxEntries: 200,
|
|
133
132
|
}),
|
|
134
133
|
],
|
|
135
134
|
context: {
|
|
136
|
-
app: process.env.APP_NAME ||
|
|
137
|
-
channel:
|
|
135
|
+
app: process.env.APP_NAME || 'refine-app',
|
|
136
|
+
channel: 'errors',
|
|
138
137
|
},
|
|
139
138
|
},
|
|
140
139
|
|
|
@@ -147,13 +146,13 @@ const loggerConfig: LoggerModuleOptions = {
|
|
|
147
146
|
audit: {
|
|
148
147
|
transporters: [
|
|
149
148
|
new StorageTransporter({
|
|
150
|
-
key:
|
|
149
|
+
key: 'audit-logs',
|
|
151
150
|
maxEntries: 1000,
|
|
152
151
|
}),
|
|
153
152
|
],
|
|
154
153
|
context: {
|
|
155
|
-
app: process.env.APP_NAME ||
|
|
156
|
-
channel:
|
|
154
|
+
app: process.env.APP_NAME || 'refine-app',
|
|
155
|
+
channel: 'audit',
|
|
157
156
|
},
|
|
158
157
|
},
|
|
159
158
|
|
|
@@ -166,6 +165,6 @@ const loggerConfig: LoggerModuleOptions = {
|
|
|
166
165
|
transporters: [new SilentTransporter()],
|
|
167
166
|
},
|
|
168
167
|
},
|
|
169
|
-
};
|
|
168
|
+
});
|
|
170
169
|
|
|
171
170
|
export default loggerConfig;
|
package/dist/index.d.cts
CHANGED
|
@@ -399,27 +399,6 @@ interface LoggerModuleOptions {
|
|
|
399
399
|
*/
|
|
400
400
|
channels: Record<string, LoggerConfig>;
|
|
401
401
|
}
|
|
402
|
-
/**
|
|
403
|
-
* Helper function to define logger configuration with type safety
|
|
404
|
-
*
|
|
405
|
-
* @param config - Logger module options
|
|
406
|
-
* @returns The same config with proper typing
|
|
407
|
-
*
|
|
408
|
-
* @example
|
|
409
|
-
* ```typescript
|
|
410
|
-
* import { defineConfig } from '@abdokouta/logger';
|
|
411
|
-
*
|
|
412
|
-
* const config = defineConfig({
|
|
413
|
-
* default: 'console',
|
|
414
|
-
* channels: {
|
|
415
|
-
* console: {
|
|
416
|
-
* transporters: [new ConsoleTransporter()],
|
|
417
|
-
* },
|
|
418
|
-
* },
|
|
419
|
-
* });
|
|
420
|
-
* ```
|
|
421
|
-
*/
|
|
422
|
-
declare function defineConfig(config: LoggerModuleOptions): LoggerModuleOptions;
|
|
423
402
|
|
|
424
403
|
/**
|
|
425
404
|
* Logger service implementation
|
|
@@ -748,6 +727,41 @@ declare class LoggerModule {
|
|
|
748
727
|
private static processConfig;
|
|
749
728
|
}
|
|
750
729
|
|
|
730
|
+
/**
|
|
731
|
+
* Define Config Utility
|
|
732
|
+
*
|
|
733
|
+
* Helper function to define logger configuration with type safety.
|
|
734
|
+
*
|
|
735
|
+
* @module @abdokouta/logger
|
|
736
|
+
*/
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Helper function to define logger configuration with type safety
|
|
740
|
+
*
|
|
741
|
+
* Provides IDE autocomplete and type checking for configuration objects.
|
|
742
|
+
* This pattern is consistent with modern tooling (Vite, Vitest, etc.).
|
|
743
|
+
*
|
|
744
|
+
* @param config - The logger configuration object
|
|
745
|
+
* @returns The same configuration object with proper typing
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* ```typescript
|
|
749
|
+
* // logger.config.ts
|
|
750
|
+
* import { defineConfig, ConsoleTransporter, LogLevel } from '@abdokouta/logger';
|
|
751
|
+
*
|
|
752
|
+
* export default defineConfig({
|
|
753
|
+
* default: 'console',
|
|
754
|
+
* channels: {
|
|
755
|
+
* console: {
|
|
756
|
+
* transporters: [new ConsoleTransporter({ level: LogLevel.Debug })],
|
|
757
|
+
* context: { app: 'my-app' },
|
|
758
|
+
* },
|
|
759
|
+
* },
|
|
760
|
+
* });
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
declare function defineConfig(config: LoggerModuleOptions): LoggerModuleOptions;
|
|
764
|
+
|
|
751
765
|
/**
|
|
752
766
|
* Pretty Formatter
|
|
753
767
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -399,27 +399,6 @@ interface LoggerModuleOptions {
|
|
|
399
399
|
*/
|
|
400
400
|
channels: Record<string, LoggerConfig>;
|
|
401
401
|
}
|
|
402
|
-
/**
|
|
403
|
-
* Helper function to define logger configuration with type safety
|
|
404
|
-
*
|
|
405
|
-
* @param config - Logger module options
|
|
406
|
-
* @returns The same config with proper typing
|
|
407
|
-
*
|
|
408
|
-
* @example
|
|
409
|
-
* ```typescript
|
|
410
|
-
* import { defineConfig } from '@abdokouta/logger';
|
|
411
|
-
*
|
|
412
|
-
* const config = defineConfig({
|
|
413
|
-
* default: 'console',
|
|
414
|
-
* channels: {
|
|
415
|
-
* console: {
|
|
416
|
-
* transporters: [new ConsoleTransporter()],
|
|
417
|
-
* },
|
|
418
|
-
* },
|
|
419
|
-
* });
|
|
420
|
-
* ```
|
|
421
|
-
*/
|
|
422
|
-
declare function defineConfig(config: LoggerModuleOptions): LoggerModuleOptions;
|
|
423
402
|
|
|
424
403
|
/**
|
|
425
404
|
* Logger service implementation
|
|
@@ -748,6 +727,41 @@ declare class LoggerModule {
|
|
|
748
727
|
private static processConfig;
|
|
749
728
|
}
|
|
750
729
|
|
|
730
|
+
/**
|
|
731
|
+
* Define Config Utility
|
|
732
|
+
*
|
|
733
|
+
* Helper function to define logger configuration with type safety.
|
|
734
|
+
*
|
|
735
|
+
* @module @abdokouta/logger
|
|
736
|
+
*/
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Helper function to define logger configuration with type safety
|
|
740
|
+
*
|
|
741
|
+
* Provides IDE autocomplete and type checking for configuration objects.
|
|
742
|
+
* This pattern is consistent with modern tooling (Vite, Vitest, etc.).
|
|
743
|
+
*
|
|
744
|
+
* @param config - The logger configuration object
|
|
745
|
+
* @returns The same configuration object with proper typing
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* ```typescript
|
|
749
|
+
* // logger.config.ts
|
|
750
|
+
* import { defineConfig, ConsoleTransporter, LogLevel } from '@abdokouta/logger';
|
|
751
|
+
*
|
|
752
|
+
* export default defineConfig({
|
|
753
|
+
* default: 'console',
|
|
754
|
+
* channels: {
|
|
755
|
+
* console: {
|
|
756
|
+
* transporters: [new ConsoleTransporter({ level: LogLevel.Debug })],
|
|
757
|
+
* context: { app: 'my-app' },
|
|
758
|
+
* },
|
|
759
|
+
* },
|
|
760
|
+
* });
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
declare function defineConfig(config: LoggerModuleOptions): LoggerModuleOptions;
|
|
764
|
+
|
|
751
765
|
/**
|
|
752
766
|
* Pretty Formatter
|
|
753
767
|
*
|