@infineit/winston-logger 1.0.39 → 1.0.40
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 +183 -43
- package/package.json +1 -2
- package/tsconfig.lib.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -45,11 +45,12 @@ npm install @infineit/winston-logger
|
|
|
45
45
|
|
|
46
46
|
This package requires the following peer dependencies (usually already installed in NestJS projects):
|
|
47
47
|
|
|
48
|
-
- `@nestjs/common` 11.1.
|
|
49
|
-
- `@nestjs/config` 4.2
|
|
50
|
-
- `@nestjs/core` 11.1.
|
|
51
|
-
- `nestjs-cls`
|
|
52
|
-
|
|
48
|
+
- `@nestjs/common` ^11.1.11
|
|
49
|
+
- `@nestjs/config` ^4.0.2
|
|
50
|
+
- `@nestjs/core` ^11.1.11
|
|
51
|
+
- `nestjs-cls` ^6.2.0 (required for CLS context management - correlation IDs)
|
|
52
|
+
|
|
53
|
+
**Note:** The `uuid` package is **NOT** required by this library. If you need correlation ID generation in your application code (e.g., in middleware), you can install `uuid` separately. The library itself does not generate correlation IDs - it only reads them from CLS context.
|
|
53
54
|
|
|
54
55
|
### ⚠️ Critical Setup Requirement
|
|
55
56
|
|
|
@@ -251,9 +252,9 @@ You can also configure via `@nestjs/config`:
|
|
|
251
252
|
```typescript
|
|
252
253
|
// .env
|
|
253
254
|
NODE_ENV=production
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
LOGGER_SLACK_INC_WEBHOOK_URL=https://hooks.slack.com/services/...
|
|
256
|
+
LOGGER_CONSOLE_PRINT=true
|
|
257
|
+
LOGGER_LOG_IN_FILE=true
|
|
257
258
|
LOGGER_ORGANIZATION=my-org
|
|
258
259
|
LOGGER_CONTEXT=user-service
|
|
259
260
|
LOGGER_APP=api-gateway
|
|
@@ -271,19 +272,24 @@ LOGGER_HTTP_ENDPOINT=https://logging-service.example.com/api/logs
|
|
|
271
272
|
// logger.config.ts
|
|
272
273
|
import { registerAs } from '@nestjs/config';
|
|
273
274
|
|
|
275
|
+
const getBooleanEnvVar = (key: string, defaultValue: boolean = false): boolean => {
|
|
276
|
+
const value = process.env[key];
|
|
277
|
+
return value ? value.toLowerCase() === 'true' : defaultValue;
|
|
278
|
+
};
|
|
279
|
+
|
|
274
280
|
export default registerAs('logger', () => ({
|
|
275
|
-
nodeEnv: process.env.NODE_ENV,
|
|
276
|
-
slack_webhook: process.env.
|
|
277
|
-
console_print:
|
|
278
|
-
log_in_file:
|
|
279
|
-
organization: process.env.LOGGER_ORGANIZATION,
|
|
280
|
-
context: process.env.LOGGER_CONTEXT,
|
|
281
|
-
app: process.env.LOGGER_APP,
|
|
281
|
+
nodeEnv: process.env.NODE_ENV || 'development',
|
|
282
|
+
slack_webhook: process.env.LOGGER_SLACK_INC_WEBHOOK_URL || undefined,
|
|
283
|
+
console_print: getBooleanEnvVar('LOGGER_CONSOLE_PRINT', false),
|
|
284
|
+
log_in_file: getBooleanEnvVar('LOGGER_LOG_IN_FILE', false),
|
|
285
|
+
organization: process.env.LOGGER_ORGANIZATION || undefined,
|
|
286
|
+
context: process.env.LOGGER_CONTEXT || undefined,
|
|
287
|
+
app: process.env.LOGGER_APP || undefined,
|
|
282
288
|
// Optional: Central log forwarding
|
|
283
|
-
forwardToCentral: process.env.LOGGER_FORWARD_TO_CENTRAL,
|
|
284
|
-
transportType: process.env.LOGGER_TRANSPORT_TYPE,
|
|
285
|
-
httpEndpoint: process.env.LOGGER_HTTP_ENDPOINT,
|
|
286
|
-
kafkaTopic: process.env.LOGGER_KAFKA_TOPIC,
|
|
289
|
+
forwardToCentral: process.env.LOGGER_FORWARD_TO_CENTRAL === 'true' || process.env.LOGGER_FORWARD_TO_CENTRAL === true,
|
|
290
|
+
transportType: process.env.LOGGER_TRANSPORT_TYPE as 'http' | 'kafka' | undefined,
|
|
291
|
+
httpEndpoint: process.env.LOGGER_HTTP_ENDPOINT || undefined,
|
|
292
|
+
kafkaTopic: process.env.LOGGER_KAFKA_TOPIC || undefined,
|
|
287
293
|
}));
|
|
288
294
|
```
|
|
289
295
|
|
|
@@ -312,17 +318,29 @@ export class AppModule {}
|
|
|
312
318
|
| `organization` | `string` | No | `undefined` | Organization or project name |
|
|
313
319
|
| `context` | `string` | No | `undefined` | Bounded context name |
|
|
314
320
|
| `app` | `string` | No | `undefined` | Application or microservice name |
|
|
315
|
-
| `forwardToCentral` | `boolean \| string` | No | `false` | Enable forwarding to centralized logging service
|
|
316
|
-
| `transportType` | `'kafka' \| 'http'` | No | `undefined` | Transport type for central forwarding
|
|
317
|
-
| `httpEndpoint` | `string` | No | `undefined` | HTTP endpoint for central forwarding
|
|
318
|
-
| `kafkaTopic` | `string` | No | `undefined` | Kafka topic for central forwarding
|
|
321
|
+
| `forwardToCentral` | `boolean \| string` | No | `false` | Enable forwarding to centralized logging service. Accepts: `true`, `false`, `'true'`, `'false'`, or `undefined`. Only `true` or `'true'` enables forwarding. |
|
|
322
|
+
| `transportType` | `'kafka' \| 'http'` | No | `undefined` | Transport type for central forwarding. **Required** if `forwardToCentral=true`. Invalid config returns `null` (logged to console.error, no exception thrown). |
|
|
323
|
+
| `httpEndpoint` | `string` | No | `undefined` | HTTP endpoint for central forwarding. **Required** if `transportType='http'`. Invalid config returns `null`. HTTP requests have 5-second timeout. |
|
|
324
|
+
| `kafkaTopic` | `string` | No | `undefined` | Kafka topic for central forwarding. **Required** if `transportType='kafka'`. Invalid config returns `null`. Requires `KafkaProducerKey` provider. |
|
|
319
325
|
|
|
320
326
|
### Default Behavior
|
|
321
327
|
|
|
322
|
-
|
|
323
|
-
- **
|
|
324
|
-
- **
|
|
325
|
-
|
|
328
|
+
**Console and File Logging:**
|
|
329
|
+
- **Development environments** (`NODE_ENV='development'` or `undefined`): Console and file logging are **automatically enabled** regardless of `console_print`/`log_in_file` settings (code: `(!isProduction && !isTesting) || consolePrint`)
|
|
330
|
+
- **Production or testing environments** (`NODE_ENV='production'` or `'testing'`): Console and file logging are **disabled by default** and must be explicitly enabled via `LOGGER_CONSOLE_PRINT=true` or `LOGGER_LOG_IN_FILE=true`
|
|
331
|
+
|
|
332
|
+
**Slack:**
|
|
333
|
+
- Only enabled in **production or testing** when `slack_webhook` is provided
|
|
334
|
+
- Disabled in development environments
|
|
335
|
+
|
|
336
|
+
**Central Forwarding:**
|
|
337
|
+
- **Disabled by default** (set `forwardToCentral=true` to enable)
|
|
338
|
+
- Requires `transportType` ('http' or 'kafka') and corresponding endpoint/topic
|
|
339
|
+
|
|
340
|
+
**Configuration Merge Precedence:**
|
|
341
|
+
- `LoggerModule.forRoot(config)` parameter takes precedence over `ConfigService` values
|
|
342
|
+
- If both are provided, parameter values override ConfigService values
|
|
343
|
+
- If forwarding is disabled (false/undefined), `CentralLogForwarder` returns `null` (no errors thrown)
|
|
326
344
|
|
|
327
345
|
### Environment-Specific Configuration Tips
|
|
328
346
|
|
|
@@ -330,10 +348,10 @@ export class AppModule {}
|
|
|
330
348
|
```bash
|
|
331
349
|
# Disable forwarding in development (optional)
|
|
332
350
|
LOGGER_FORWARD_TO_CENTRAL=false
|
|
333
|
-
# OR use local endpoint for testing
|
|
351
|
+
# OR use local endpoint for testing (separate service/port required)
|
|
334
352
|
LOGGER_FORWARD_TO_CENTRAL=true
|
|
335
353
|
LOGGER_TRANSPORT_TYPE=http
|
|
336
|
-
LOGGER_HTTP_ENDPOINT=http://
|
|
354
|
+
LOGGER_HTTP_ENDPOINT=http://127.0.0.1:3062/api/logs # Different port/service
|
|
337
355
|
```
|
|
338
356
|
|
|
339
357
|
**Production:**
|
|
@@ -341,7 +359,7 @@ LOGGER_HTTP_ENDPOINT=http://localhost:3000/api/logs
|
|
|
341
359
|
# Enable forwarding in production
|
|
342
360
|
LOGGER_FORWARD_TO_CENTRAL=true
|
|
343
361
|
LOGGER_TRANSPORT_TYPE=http
|
|
344
|
-
LOGGER_HTTP_ENDPOINT=https://central-logging.example.com/api/logs
|
|
362
|
+
LOGGER_HTTP_ENDPOINT=https://central-logging.example.com/api/logs # Separate service
|
|
345
363
|
# OR use Kafka for better performance
|
|
346
364
|
# LOGGER_TRANSPORT_TYPE=kafka
|
|
347
365
|
# LOGGER_KAFKA_TOPIC=project-logs-<project-name>
|
|
@@ -796,18 +814,18 @@ Central log forwarding is completely fire-and-forget:
|
|
|
796
814
|
# Option 1: Disable forwarding in development
|
|
797
815
|
LOGGER_FORWARD_TO_CENTRAL=false
|
|
798
816
|
|
|
799
|
-
# Option 2: Use local endpoint for testing
|
|
817
|
+
# Option 2: Use local endpoint for testing (separate service/port required)
|
|
800
818
|
LOGGER_FORWARD_TO_CENTRAL=true
|
|
801
819
|
LOGGER_TRANSPORT_TYPE=http
|
|
802
|
-
LOGGER_HTTP_ENDPOINT=http://
|
|
820
|
+
LOGGER_HTTP_ENDPOINT=http://127.0.0.1:3062/api/logs # Different port/service
|
|
803
821
|
```
|
|
804
822
|
|
|
805
823
|
**Production:**
|
|
806
824
|
```bash
|
|
807
|
-
# HTTP forwarding (simpler setup)
|
|
825
|
+
# HTTP forwarding (simpler setup, separate service required)
|
|
808
826
|
LOGGER_FORWARD_TO_CENTRAL=true
|
|
809
827
|
LOGGER_TRANSPORT_TYPE=http
|
|
810
|
-
LOGGER_HTTP_ENDPOINT=https://central-logging.example.com/api/logs
|
|
828
|
+
LOGGER_HTTP_ENDPOINT=https://central-logging.example.com/api/logs # Separate service
|
|
811
829
|
|
|
812
830
|
# OR Kafka forwarding (better performance, requires Kafka producer)
|
|
813
831
|
LOGGER_FORWARD_TO_CENTRAL=true
|
|
@@ -831,11 +849,16 @@ LOGGER_KAFKA_TOPIC=project-logs-common
|
|
|
831
849
|
### Troubleshooting
|
|
832
850
|
|
|
833
851
|
**Forwarding Not Working:**
|
|
834
|
-
1. Check configuration: `LOGGER_FORWARD_TO_CENTRAL` must be `'true'` or `true`
|
|
835
|
-
2. Verify transport type: Must be `'http'` or `'kafka'`
|
|
836
|
-
3. Check endpoint/topic: Must be configured correctly
|
|
837
|
-
4. For Kafka: Ensure `KafkaProducerKey` is provided in module providers
|
|
838
|
-
5. Check console errors: Forwarding errors are logged to `console.error` with
|
|
852
|
+
1. Check configuration: `LOGGER_FORWARD_TO_CENTRAL` must be `'true'` or `true` (not `'false'`, `false`, or `undefined`)
|
|
853
|
+
2. Verify transport type: Must be exactly `'http'` or `'kafka'` (case-sensitive)
|
|
854
|
+
3. Check endpoint/topic: Must be configured correctly (HTTP endpoint must be valid URL, Kafka topic must be non-empty string)
|
|
855
|
+
4. For Kafka: Ensure `KafkaProducerKey` is provided in module providers (otherwise forwarding is silently skipped)
|
|
856
|
+
5. Check console errors: Forwarding errors are logged to `console.error` with messages:
|
|
857
|
+
- `"CentralLogForwarder: Invalid configuration - transportType and endpoint/topic required"` (factory returns `null` for invalid config)
|
|
858
|
+
- `"[HttpCentralLogForwarder] Forward error (swallowed): <error>"` (HTTP forwarding errors during forward())
|
|
859
|
+
- `"HttpCentralLogForwarder error (swallowed): <error>"` (HTTP request errors)
|
|
860
|
+
- `"KafkaCentralLogForwarder forward error (swallowed): <error>"` (Kafka forwarding errors)
|
|
861
|
+
- `"KafkaCentralLogForwarder send error (swallowed): <error>"` (Kafka producer send() errors)
|
|
839
862
|
|
|
840
863
|
**Correlation ID Missing:**
|
|
841
864
|
- Ensure `ContextModule` is imported: `ContextModule` automatically configures `ClsModule` with `generateId: true`
|
|
@@ -843,10 +866,11 @@ LOGGER_KAFKA_TOPIC=project-logs-common
|
|
|
843
866
|
- Check that original logs have `correlationId` field (if not, forwarded logs won't either)
|
|
844
867
|
|
|
845
868
|
**HTTP Forwarding Timeout:**
|
|
846
|
-
- HTTP forwarding has a 5-second timeout
|
|
847
|
-
- Timeouts are swallowed (no errors thrown)
|
|
848
|
-
-
|
|
849
|
-
-
|
|
869
|
+
- HTTP forwarding has a **5-second timeout** (code: `req.setTimeout(5000)`)
|
|
870
|
+
- Timeouts are swallowed (no errors thrown, request destroyed silently)
|
|
871
|
+
- If timeout occurs, request is destroyed (`req.destroy()`) and error is logged to `console.error`
|
|
872
|
+
- Consider using Kafka instead if central service is slow or unreliable
|
|
873
|
+
- Or improve central service performance/availability
|
|
850
874
|
|
|
851
875
|
**Note:** Forwarding failures do not affect your application. Original logging continues normally, and business logic is never impacted.
|
|
852
876
|
|
|
@@ -2272,6 +2296,122 @@ export class AppModule {}
|
|
|
2272
2296
|
|
|
2273
2297
|
---
|
|
2274
2298
|
|
|
2299
|
+
---
|
|
2300
|
+
|
|
2301
|
+
## Configuration Truth Table
|
|
2302
|
+
|
|
2303
|
+
### Environment Variable → Behavior Mapping
|
|
2304
|
+
|
|
2305
|
+
| Environment Variable | Value | Behavior |
|
|
2306
|
+
|---------------------|-------|----------|
|
|
2307
|
+
| `NODE_ENV` | `'production'` or `'testing'` | Console/file logging **disabled by default** (must explicitly set `LOGGER_CONSOLE_PRINT=true` or `LOGGER_LOG_IN_FILE=true`); Slack enabled if webhook provided |
|
|
2308
|
+
| `NODE_ENV` | `'development'` or `undefined` | Console/file logging **enabled automatically** (code: `(!isProduction && !isTesting) || consolePrint`); `console_print`/`log_in_file` settings ignored |
|
|
2309
|
+
| `LOGGER_CONSOLE_PRINT` | `true` or `'true'` | Console logging enabled (overrides environment default) |
|
|
2310
|
+
| `LOGGER_CONSOLE_PRINT` | `false`, `'false'`, or `undefined` | Console logging follows environment default (disabled in prod/testing, enabled in development) |
|
|
2311
|
+
| `LOGGER_LOG_IN_FILE` | `true` or `'true'` | File logging enabled (overrides environment default) |
|
|
2312
|
+
| `LOGGER_LOG_IN_FILE` | `false`, `'false'`, or `undefined` | File logging follows environment default (disabled in prod/testing, enabled in development) |
|
|
2313
|
+
| `LOGGER_FORWARD_TO_CENTRAL` | `true` or `'true'` | Central forwarding **enabled** (requires `transportType` and endpoint/topic) |
|
|
2314
|
+
| `LOGGER_FORWARD_TO_CENTRAL` | `false`, `'false'`, `undefined`, or not set | Central forwarding **disabled** (returns `null`, no errors) |
|
|
2315
|
+
| `LOGGER_TRANSPORT_TYPE` | `'http'` | HTTP forwarding enabled (requires `LOGGER_HTTP_ENDPOINT`) |
|
|
2316
|
+
| `LOGGER_TRANSPORT_TYPE` | `'kafka'` | Kafka forwarding enabled (requires `LOGGER_KAFKA_TOPIC` and `KafkaProducerKey` provider) |
|
|
2317
|
+
| `LOGGER_TRANSPORT_TYPE` | Invalid or `undefined` | Forwarding disabled (returns `null`, logs error to console.error) |
|
|
2318
|
+
| `LOGGER_HTTP_ENDPOINT` | Valid URL | HTTP forwarding active (5-second timeout) |
|
|
2319
|
+
| `LOGGER_HTTP_ENDPOINT` | Invalid or `undefined` | Forwarding disabled if `transportType='http'` (returns `null`, logs error) |
|
|
2320
|
+
| `LOGGER_KAFKA_TOPIC` | Valid string | Kafka forwarding active (if `KafkaProducerKey` provided) |
|
|
2321
|
+
| `LOGGER_KAFKA_TOPIC` | `undefined` | Forwarding disabled if `transportType='kafka'` (returns `null`, logs error) |
|
|
2322
|
+
|
|
2323
|
+
### Configuration Precedence Rules
|
|
2324
|
+
|
|
2325
|
+
1. **`LoggerModule.forRoot(config)` parameter** takes precedence over `ConfigService` values
|
|
2326
|
+
2. If `forwardToCentral` is `false`, `undefined`, or invalid → `CentralLogForwarder` returns `null` (no exceptions)
|
|
2327
|
+
3. If `transportType` or endpoint/topic is invalid → `CentralLogForwarder` returns `null` (logs error, no exceptions)
|
|
2328
|
+
4. Invalid configuration does **not** throw errors - failures are swallowed to preserve fire-and-forget behavior
|
|
2329
|
+
|
|
2330
|
+
---
|
|
2331
|
+
|
|
2332
|
+
## Code Audit Summary
|
|
2333
|
+
|
|
2334
|
+
### Verified Behavior (as implemented)
|
|
2335
|
+
|
|
2336
|
+
**Configuration Reading:**
|
|
2337
|
+
- Configuration can be provided via `LoggerModule.forRoot(config)` parameter OR `ConfigService`
|
|
2338
|
+
- Parameter config takes precedence over `ConfigService` when both are provided
|
|
2339
|
+
- Factory merges both sources: `loggerConfig.forwardToCentral ?? configFromService?.forwardToCentral`
|
|
2340
|
+
- Invalid configuration returns `null` (does not throw exceptions)
|
|
2341
|
+
|
|
2342
|
+
**Environment-Based Defaults:**
|
|
2343
|
+
- **Non-production/non-testing**: Console and file transports automatically enabled (code: `(!isProduction && !isTesting) || consolePrint`)
|
|
2344
|
+
- **Production/testing**: Console and file transports disabled unless explicitly enabled via `console_print`/`log_in_file`
|
|
2345
|
+
- Slack transport only enabled in production/testing when `slack_webhook` is provided
|
|
2346
|
+
|
|
2347
|
+
**Central Forwarding:**
|
|
2348
|
+
- `forwardToCentral` must be exactly `true` or `'true'` to enable (string comparison: `=== 'true'`)
|
|
2349
|
+
- HTTP forwarding uses Node.js built-in `http`/`https` modules (no external dependencies)
|
|
2350
|
+
- HTTP requests have 5-second timeout (code: `req.setTimeout(5000)`)
|
|
2351
|
+
- Kafka forwarding requires `KafkaProducerKey` provider (optional injection, returns `null` if not provided)
|
|
2352
|
+
- Forwarding failures are swallowed (logged to `console.error`, never throw)
|
|
2353
|
+
|
|
2354
|
+
**Fire-and-Forget Guarantee:**
|
|
2355
|
+
- All logging methods return `void` (non-blocking)
|
|
2356
|
+
- All transport errors are caught and swallowed (never propagate)
|
|
2357
|
+
- Central forwarding errors are caught at multiple levels (forwarder, service, transport)
|
|
2358
|
+
- No async/await in logging code (all synchronous fire-and-forget)
|
|
2359
|
+
|
|
2360
|
+
**Dependency Injection:**
|
|
2361
|
+
- `LoggerService` is provided both via `LoggerKey` (Symbol) and class token
|
|
2362
|
+
- Direct class injection works: `constructor(private readonly logger: LoggerService)`
|
|
2363
|
+
- `CentralLogForwarder` is optional injection (`@Optional()`) - returns `null` if not configured
|
|
2364
|
+
- `KafkaProducerKey` is optional injection in factory - returns `null` if not provided
|
|
2365
|
+
|
|
2366
|
+
**CLS Integration:**
|
|
2367
|
+
- `ContextModule` uses `nestjs-cls@6.2.0` (not 5.0.1) with `mount: true` and `generateId: true`
|
|
2368
|
+
- Correlation ID is optional (`undefined` is valid)
|
|
2369
|
+
- Correlation ID is included in HTTP header (`x-correlation-id`) when forwarding
|
|
2370
|
+
- Correlation ID is included in Kafka message key and headers when forwarding
|
|
2371
|
+
|
|
2372
|
+
### Unused / Removable Dependencies (Safe to Remove)
|
|
2373
|
+
|
|
2374
|
+
**Root `package.json` (`/package.json`):**
|
|
2375
|
+
- `uuid` (version 13.0.0) - **NOT used in library code** (`libs/src/`). Only appears in README examples. **Safe to remove** if application code (`apps/`) doesn't use it for correlation ID generation.
|
|
2376
|
+
|
|
2377
|
+
**Note:** The library does **not** generate correlation IDs. Applications must either:
|
|
2378
|
+
- Rely on `ContextModule`'s automatic generation (HTTP contexts via `ClsModule` with `generateId: true`)
|
|
2379
|
+
- Generate IDs manually in application code (e.g., middleware, Kafka consumers)
|
|
2380
|
+
- Pass correlation IDs from external sources (HTTP headers, Kafka message headers)
|
|
2381
|
+
|
|
2382
|
+
**Library `package.json` (`libs/package.json`):**
|
|
2383
|
+
- ✅ **REMOVED**: `@types/uuid` (version ^9.0.6) - **NOT used** in library code. Removed from devDependencies.
|
|
2384
|
+
- All other dependencies are **verified as used**:
|
|
2385
|
+
- `@nestjs/common`, `@nestjs/config`, `@nestjs/core` - Core NestJS dependencies
|
|
2386
|
+
- `nestjs-cls@6.2.0` - Used in `ContextModule` and `NestjsClsContextStorageService`
|
|
2387
|
+
- `winston`, `winston-daily-rotate-file`, `winston-slack-webhook-transport` - Used in Winston transports
|
|
2388
|
+
- `reflect-metadata`, `rxjs` - Required by NestJS
|
|
2389
|
+
|
|
2390
|
+
**Dead Code (Not Removed - Exported for Manual Use):**
|
|
2391
|
+
- `CentralLogForwarder` class exists but is **not used by `LoggerModule`**. The module factory creates `HttpCentralLogForwarder` or `KafkaCentralLogForwarder` directly. However, the class is exported in `index.ts` for potential manual use, so it's kept for backward compatibility.
|
|
2392
|
+
|
|
2393
|
+
### Environment Variable Name Corrections
|
|
2394
|
+
|
|
2395
|
+
**Actual environment variable names (as implemented in `apps/src/config/logger.config.ts`):**
|
|
2396
|
+
- ✅ `LOGGER_SLACK_INC_WEBHOOK_URL` (not `SLACK_WEBHOOK`)
|
|
2397
|
+
- ✅ `LOGGER_CONSOLE_PRINT` (not `CONSOLE_PRINT`)
|
|
2398
|
+
- ✅ `LOGGER_LOG_IN_FILE` (not `LOG_IN_FILE`)
|
|
2399
|
+
- ✅ `LOGGER_ORGANIZATION`, `LOGGER_CONTEXT`, `LOGGER_APP` (correct)
|
|
2400
|
+
- ✅ `LOGGER_FORWARD_TO_CENTRAL`, `LOGGER_TRANSPORT_TYPE`, `LOGGER_HTTP_ENDPOINT`, `LOGGER_KAFKA_TOPIC` (correct)
|
|
2401
|
+
|
|
2402
|
+
### Fail-Fast Behavior
|
|
2403
|
+
|
|
2404
|
+
**Important:** The library does **NOT** fail-fast for invalid configuration:
|
|
2405
|
+
- Invalid `forwardToCentral` → Returns `null`, no error thrown
|
|
2406
|
+
- Invalid `transportType` → Returns `null`, logs to `console.error`, no exception
|
|
2407
|
+
- Missing `httpEndpoint` or `kafkaTopic` → Returns `null`, logs to `console.error`, no exception
|
|
2408
|
+
- Invalid HTTP endpoint URL → Constructor throws (expected - invalid URL is a programming error)
|
|
2409
|
+
- Missing `KafkaProducerKey` → Kafka forwarding silently skipped (returns `null`, no error)
|
|
2410
|
+
|
|
2411
|
+
**Rationale:** Fail-fast behavior would violate the fire-and-forget guarantee. Invalid configuration should not crash the application - it should gracefully degrade (disable forwarding) and log the issue.
|
|
2412
|
+
|
|
2413
|
+
---
|
|
2414
|
+
|
|
2275
2415
|
## License
|
|
2276
2416
|
|
|
2277
2417
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infineit/winston-logger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
4
4
|
"description": "Enterprise-level logger integration package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"winston-slack-webhook-transport": "2.3.6"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/uuid": "^9.0.6",
|
|
25
24
|
"@types/winston": "^2.4.4",
|
|
26
25
|
"rimraf": "^6.0.1"
|
|
27
26
|
},
|