@edirect/logger 11.0.48 → 11.0.50

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 CHANGED
@@ -91,38 +91,38 @@ export class OrderService {
91
91
 
92
92
  ### `LoggerService` methods
93
93
 
94
- | Method | Signature | Description |
95
- |--------|-----------|-------------|
96
- | `log` | `(message: string, payload?: string): void` | Alias for `info` |
97
- | `info` | `(message: string, payload?: string): void` | Log at INFO level |
98
- | `warn` | `(message: string, payload?: string): void` | Log at WARN level |
99
- | `error` | `(message: string, trace: string): void` | Log at ERROR level |
100
- | `debug` | `(message: string): void` | Log at DEBUG level |
101
- | `verbose` | `(message: string): void` | Log at VERBOSE level (maps to INFO internally) |
102
- | `setSessionId` | `(sessionId: string): void` | Attach a session ID to all subsequent log entries |
103
- | `setQuoteId` | `(quoteId: string): void` | Attach a quote/correlation ID to all subsequent log entries |
94
+ | Method | Signature | Description |
95
+ | -------------- | ------------------------------------------- | ----------------------------------------------------------- |
96
+ | `log` | `(message: string, payload?: string): void` | Alias for `info` |
97
+ | `info` | `(message: string, payload?: string): void` | Log at INFO level |
98
+ | `warn` | `(message: string, payload?: string): void` | Log at WARN level |
99
+ | `error` | `(message: string, trace: string): void` | Log at ERROR level |
100
+ | `debug` | `(message: string): void` | Log at DEBUG level |
101
+ | `verbose` | `(message: string): void` | Log at VERBOSE level (maps to INFO internally) |
102
+ | `setSessionId` | `(sessionId: string): void` | Attach a session ID to all subsequent log entries |
103
+ | `setQuoteId` | `(quoteId: string): void` | Attach a quote/correlation ID to all subsequent log entries |
104
104
 
105
105
  ### `LoggerModuleOptions`
106
106
 
107
- | Option | Type | Default | Description |
108
- |--------|------|---------|-------------|
109
- | `level` | `pino.Level` | `'info'` | Minimum log level |
110
- | `name` | `string` | `npm_package_name \| 'app'` | Service name in every log entry |
111
- | `version` | `string` | `npm_package_version \| '0.0.0'` | Service version in every log entry |
112
- | `host` | `string` | `'0.0.0.0'` | Host tag |
113
- | `protocol` | `string` | `'http'` | Protocol tag |
107
+ | Option | Type | Default | Description |
108
+ | ---------- | ------------ | -------------------------------- | ---------------------------------- |
109
+ | `level` | `pino.Level` | `'info'` | Minimum log level |
110
+ | `name` | `string` | `npm_package_name \| 'app'` | Service name in every log entry |
111
+ | `version` | `string` | `npm_package_version \| '0.0.0'` | Service version in every log entry |
112
+ | `host` | `string` | `'0.0.0.0'` | Host tag |
113
+ | `protocol` | `string` | `'http'` | Protocol tag |
114
114
 
115
115
  ## Environment Variables
116
116
 
117
117
  When options are not passed explicitly, the logger reads from environment variables:
118
118
 
119
- | Variable | Description | Default |
120
- |----------|-------------|---------|
121
- | `LOGS_LEVEL` | Log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`) | `info` |
122
- | `LOGS_HOST` | Host tag in log entries | `0.0.0.0` |
123
- | `LOGS_PROTOCOL` | Protocol tag in log entries | `http` |
124
- | `APP_NAME` | Service name | `npm_package_name` or `app` |
125
- | `APP_VERSION` | Service version | `npm_package_version` or `0.0.0` |
119
+ | Variable | Description | Default |
120
+ | --------------- | -------------------------------------------------------------- | -------------------------------- |
121
+ | `LOGS_LEVEL` | Log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`) | `info` |
122
+ | `LOGS_HOST` | Host tag in log entries | `0.0.0.0` |
123
+ | `LOGS_PROTOCOL` | Protocol tag in log entries | `http` |
124
+ | `APP_NAME` | Service name | `npm_package_name` or `app` |
125
+ | `APP_VERSION` | Service version | `npm_package_version` or `0.0.0` |
126
126
 
127
127
  ## Log Output Format
128
128
 
package/dist/README.md CHANGED
@@ -1,59 +1,60 @@
1
1
  # @edirect/logger
2
2
 
3
- Structured logging module for eDirect NestJS applications. Built on top of [Pino](https://github.com/pinojs/pino), providing high-performance JSON logging to stdout/stderr, configurable log levels, and correlation ID tracking (sessionId / quoteId).
3
+ Advanced logging module for Edirect applications. Provides structured, multi-level logging with support for file output, async configuration, and integration with NestJS and Edirect config modules.
4
4
 
5
5
  ## Features
6
6
 
7
- - Structured JSON logs with consistent field names (`message`, `level`, `timestamp`, `name`, `version`)
8
- - Outputs to stdout/stderr
9
- - Configurable log level via environment variable or module options
10
- - Tracks `sessionId` and `quoteId` as correlation context in all log entries
11
- - Global module — register once, inject `LoggerService` anywhere
12
- - Supports both sync (`register`) and async (`registerAsync`) configuration
7
+ - Multi-level logging (log, info, warn, error, debug, verbose)
8
+ - File and console output
9
+ - Async configuration with ConfigService
10
+ - Integrates with NestJS
13
11
 
14
12
  ## Installation
15
13
 
16
- ```sh
17
- pnpm add @edirect/logger
18
- # or
14
+ ```bash
19
15
  npm install @edirect/logger
20
16
  ```
21
17
 
22
18
  ## Usage
23
19
 
24
- ### Simple registration (static options)
20
+ Register LoggerModule in your AppModule:
25
21
 
26
- ```ts
27
- import { Module } from '@nestjs/common';
22
+ ```typescript
28
23
  import { LoggerModule } from '@edirect/logger';
29
24
 
30
25
  @Module({
31
26
  imports: [
32
27
  LoggerModule.register({
33
- output: 'console',
34
- level: 'info',
35
- name: 'my-service',
28
+ output: 'output',
29
+ logs: {
30
+ errorFile: 'error_file',
31
+ warningFile: 'warning_file',
32
+ infoFile: 'info_file',
33
+ },
34
+ name: 'subscription-service',
36
35
  }),
37
36
  ],
38
37
  })
39
38
  export class AppModule {}
40
39
  ```
41
40
 
42
- ### Async registration (with ConfigService)
41
+ Or use async configuration:
43
42
 
44
- ```ts
45
- import { Module } from '@nestjs/common';
46
- import { ConfigModule, ConfigService } from '@edirect/config';
47
- import { LoggerModule } from '@edirect/logger';
43
+ ```typescript
44
+ import { ConfigService } from '@edirect/config';
48
45
 
49
46
  @Module({
50
47
  imports: [
51
- ConfigModule,
52
48
  LoggerModule.registerAsync({
53
49
  imports: [ConfigModule],
54
- useFactory: (configService: ConfigService) => ({
55
- level: (configService.get('LOGS_LEVEL') as any) ?? 'info',
56
- name: configService.get('APP_NAME') ?? 'app',
50
+ useFactory: async (configService: ConfigService) => ({
51
+ output: configService.get(Variables.LOGS_OUTPUT),
52
+ logs: {
53
+ errorFile: configService.get(Variables.LOGS_ERROR_FILE),
54
+ warningFile: configService.get(Variables.LOGS_WARNING_FILE),
55
+ infoFile: configService.get(Variables.LOGS_INFO_FILE),
56
+ },
57
+ name: 'subscription-service',
57
58
  }),
58
59
  inject: [ConfigService],
59
60
  }),
@@ -62,84 +63,34 @@ import { LoggerModule } from '@edirect/logger';
62
63
  export class AppModule {}
63
64
  ```
64
65
 
65
- ### Inject and use LoggerService
66
-
67
- ```ts
68
- import { Injectable } from '@nestjs/common';
69
- import { LoggerService } from '@edirect/logger';
70
-
71
- @Injectable()
72
- export class OrderService {
73
- constructor(private readonly logger: LoggerService) {}
74
-
75
- async processOrder(orderId: string, sessionId: string) {
76
- this.logger.setSessionId(sessionId);
77
- this.logger.setQuoteId(orderId);
78
-
79
- this.logger.info('Processing order', JSON.stringify({ orderId }));
80
- try {
81
- // business logic...
82
- this.logger.log('Order processed successfully');
83
- } catch (err) {
84
- this.logger.error('Order processing failed', (err as Error).stack ?? '');
85
- }
86
- }
87
- }
66
+ Inject LoggerService and use logging methods:
67
+
68
+ ```typescript
69
+ constructor(private loggerService: LoggerService) {}
70
+
71
+ this.loggerService.log('message', payload);
72
+ this.loggerService.info('message', payload);
73
+ this.loggerService.warn('message', payload);
74
+ this.loggerService.error('message', trace);
75
+ this.loggerService.debug('message');
76
+ this.loggerService.verbose('message');
88
77
  ```
89
78
 
90
- ## API
91
-
92
- ### `LoggerService` methods
93
-
94
- | Method | Signature | Description |
95
- |--------|-----------|-------------|
96
- | `log` | `(message: string, payload?: string): void` | Alias for `info` |
97
- | `info` | `(message: string, payload?: string): void` | Log at INFO level |
98
- | `warn` | `(message: string, payload?: string): void` | Log at WARN level |
99
- | `error` | `(message: string, trace: string): void` | Log at ERROR level |
100
- | `debug` | `(message: string): void` | Log at DEBUG level |
101
- | `verbose` | `(message: string): void` | Log at VERBOSE level (maps to INFO internally) |
102
- | `setSessionId` | `(sessionId: string): void` | Attach a session ID to all subsequent log entries |
103
- | `setQuoteId` | `(quoteId: string): void` | Attach a quote/correlation ID to all subsequent log entries |
104
-
105
- ### `LoggerModuleOptions`
106
-
107
- | Option | Type | Default | Description |
108
- |--------|------|---------|-------------|
109
- | `level` | `pino.Level` | `'info'` | Minimum log level |
110
- | `name` | `string` | `npm_package_name \| 'app'` | Service name in every log entry |
111
- | `version` | `string` | `npm_package_version \| '0.0.0'` | Service version in every log entry |
112
- | `host` | `string` | `'0.0.0.0'` | Host tag |
113
- | `protocol` | `string` | `'http'` | Protocol tag |
114
-
115
- ## Environment Variables
116
-
117
- When options are not passed explicitly, the logger reads from environment variables:
118
-
119
- | Variable | Description | Default |
120
- |----------|-------------|---------|
121
- | `LOGS_LEVEL` | Log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`) | `info` |
122
- | `LOGS_HOST` | Host tag in log entries | `0.0.0.0` |
123
- | `LOGS_PROTOCOL` | Protocol tag in log entries | `http` |
124
- | `APP_NAME` | Service name | `npm_package_name` or `app` |
125
- | `APP_VERSION` | Service version | `npm_package_version` or `0.0.0` |
126
-
127
- ## Log Output Format
128
-
129
- Every log entry is a JSON object:
130
-
131
- ```json
132
- {
133
- "level": "info",
134
- "timestamp": "2024-01-15T10:30:00.000Z",
135
- "name": "payment-gateway",
136
- "version": "1.2.3",
137
- "host": "pod-abc-123",
138
- "protocol": "http",
139
- "sessionId": "session-abc-123",
140
- "quoteId": "quote-xyz-456",
141
- "remote-address": "",
142
- "message": "Order created successfully",
143
- "payload": { "orderId": "ORD-789" }
144
- }
79
+ Inject the LoggerService where needed:
80
+
81
+ ```typescript
82
+ constructor(
83
+ private loggerService: LoggerService
84
+ ) {}
85
+ ```
86
+
87
+ Log using the exposed methods:
88
+
89
+ ```typescript
90
+ this.loggerService.log(message: string, payload?: string)
91
+ this.loggerService.info(message: string, payload?: string)
92
+ this.loggerService.warn(message: string, payload: string)
93
+ this.loggerService.error(message: string, trace: string)
94
+ this.loggerService.debug(message: string)
95
+ this.loggerService.verbose(message: string)
145
96
  ```
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/logger",
3
- "version": "11.0.48",
3
+ "version": "11.0.46",
4
4
  "main": "./dist/src/index.js",
5
5
  "types": "./dist/src/index.d.ts",
6
6
  "exports": {
@@ -16,9 +16,9 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@edirect/config": "^11.0.48",
20
- "@nestjs/common": "^11.1.15",
21
- "pino": "10.3.1",
19
+ "@edirect/config": "^11.0.46",
20
+ "@nestjs/common": "^11.1.12",
21
+ "pino": "10.3.0",
22
22
  "supertest": "7.2.2",
23
23
  "tslib": "^2.8.1"
24
24
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/logger",
3
- "version": "11.0.48",
3
+ "version": "11.0.50",
4
4
  "packageScope": "@edirect",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -17,11 +17,11 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "@nestjs/common": "^11.1.15",
20
+ "@nestjs/common": "^11.1.16",
21
21
  "pino": "10.3.1",
22
22
  "supertest": "7.2.2",
23
23
  "tslib": "^2.8.1",
24
- "@edirect/config": "11.0.48"
24
+ "@edirect/config": "11.0.50"
25
25
  },
26
26
  "nx": {
27
27
  "name": "@edirect/logger",