@rxap/nest-logger 11.0.0-dev.4 → 11.0.0-dev.6
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/CHANGELOG.md +10 -0
- package/package.json +6 -6
- package/src/lib/logger.d.ts +4 -1
- package/src/lib/logger.js +23 -5
- package/src/lib/tokens.d.ts +1 -0
- package/src/lib/tokens.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [11.0.0-dev.6](https://gitlab.com/rxap/packages/compare/@rxap/nest-logger@11.0.0-dev.5...@rxap/nest-logger@11.0.0-dev.6) (2025-11-21)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **logger:** add customizable message formatting in RxapLogger ([9fabbaa](https://gitlab.com/rxap/packages/commit/9fabbaa08c44531d6425a5af15247d41a09623ef))
|
|
11
|
+
|
|
12
|
+
# [11.0.0-dev.5](https://gitlab.com/rxap/packages/compare/@rxap/nest-logger@11.0.0-dev.4...@rxap/nest-logger@11.0.0-dev.5) (2025-09-18)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @rxap/nest-logger
|
|
15
|
+
|
|
6
16
|
# [11.0.0-dev.4](https://gitlab.com/rxap/packages/compare/@rxap/nest-logger@11.0.0-dev.3...@rxap/nest-logger@11.0.0-dev.4) (2025-09-15)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @rxap/nest-logger
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "11.0.0-dev.
|
|
2
|
+
"version": "11.0.0-dev.6",
|
|
3
3
|
"name": "@rxap/nest-logger",
|
|
4
4
|
"description": "A NestJS logger module that integrates with Google Cloud Logging and provides enhanced message formatting. It allows for custom print message functions and circular dependency handling. This package offers a convenient way to standardize and enrich logging within NestJS applications.\n",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@nx/devkit": "20.5.0",
|
|
8
|
-
"@rxap/ts-morph": "^1.6.0-dev.
|
|
9
|
-
"@rxap/workspace-utilities": "^19.8.1-dev.
|
|
8
|
+
"@rxap/ts-morph": "^1.6.0-dev.2",
|
|
9
|
+
"@rxap/workspace-utilities": "^19.8.1-dev.2",
|
|
10
10
|
"tslib": "2.6.2"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@nestjs/common": "^11.1.1",
|
|
14
14
|
"@rxap/nest-utilities": "^11.0.0-dev.7",
|
|
15
|
-
"@rxap/utilities": "^16.
|
|
15
|
+
"@rxap/utilities": "^16.5.0-dev.0"
|
|
16
16
|
},
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Merzough Münker",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"package": "@rxap/utilities",
|
|
66
|
-
"version": "16.
|
|
66
|
+
"version": "16.5.0-dev.0"
|
|
67
67
|
}
|
|
68
68
|
]
|
|
69
69
|
},
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
"schematics": "./generators.json",
|
|
80
80
|
"type": "commonjs",
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "5a9ae8f2c234aa1e15981d3be09aec876b3dee5c",
|
|
82
82
|
"types": "./src/index.d.ts",
|
|
83
83
|
"main": "./src/index.js"
|
|
84
84
|
}
|
package/src/lib/logger.d.ts
CHANGED
|
@@ -3,14 +3,17 @@ import { ConsoleLogger, ConsoleLoggerOptions, LogLevel } from '@nestjs/common';
|
|
|
3
3
|
* @return true - call the super.printMessages method
|
|
4
4
|
*/
|
|
5
5
|
export type PrintMessagesFunction = (messages: unknown[], context: string, logLevel: LogLevel, writeStreamType?: 'stdout' | 'stderr') => boolean;
|
|
6
|
+
export type FormatMessageFunction = (pidMessage: string, timestamp: string, formattedLogLevel: string, contextMessage: string, output: string, timestampDiff: string) => string;
|
|
6
7
|
/**
|
|
7
8
|
* A custom logger class that extends the ConsoleLogger class.
|
|
8
9
|
* This class provides additional methods for logging at different log levels and supports the interpolation of optional parameters.
|
|
9
10
|
*/
|
|
10
11
|
export declare class RxapLogger extends ConsoleLogger {
|
|
11
12
|
protected readonly printMessagesFunction: PrintMessagesFunction | null;
|
|
12
|
-
|
|
13
|
+
protected readonly formatMessageFunction: FormatMessageFunction | null;
|
|
14
|
+
constructor(context?: string, options?: ConsoleLoggerOptions);
|
|
13
15
|
protected interpolate(messages: unknown[]): unknown[];
|
|
14
16
|
protected stringifyCircular(obj: any): string;
|
|
17
|
+
protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
|
|
15
18
|
protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr'): void;
|
|
16
19
|
}
|
package/src/lib/logger.js
CHANGED
|
@@ -9,9 +9,10 @@ const tokens_1 = require("./tokens");
|
|
|
9
9
|
* This class provides additional methods for logging at different log levels and supports the interpolation of optional parameters.
|
|
10
10
|
*/
|
|
11
11
|
let RxapLogger = class RxapLogger extends common_1.ConsoleLogger {
|
|
12
|
-
constructor(context, options = {}
|
|
12
|
+
constructor(context, options = {}) {
|
|
13
13
|
super(context, options);
|
|
14
|
-
this.printMessagesFunction =
|
|
14
|
+
this.printMessagesFunction = null;
|
|
15
|
+
this.formatMessageFunction = null;
|
|
15
16
|
}
|
|
16
17
|
interpolate(messages) {
|
|
17
18
|
if (messages.length <= 1) {
|
|
@@ -66,6 +67,15 @@ let RxapLogger = class RxapLogger extends common_1.ConsoleLogger {
|
|
|
66
67
|
return value;
|
|
67
68
|
});
|
|
68
69
|
}
|
|
70
|
+
formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff) {
|
|
71
|
+
const output = this.stringifyMessage(message, logLevel);
|
|
72
|
+
pidMessage = this.colorize(pidMessage, logLevel);
|
|
73
|
+
formattedLogLevel = this.colorize(formattedLogLevel, logLevel);
|
|
74
|
+
if (this.formatMessageFunction) {
|
|
75
|
+
return this.formatMessageFunction(pidMessage, this.getTimestamp(), formattedLogLevel, contextMessage, output, timestampDiff);
|
|
76
|
+
}
|
|
77
|
+
return `${pidMessage}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${output}${timestampDiff}\n`;
|
|
78
|
+
}
|
|
69
79
|
printMessages(messages, context = '', logLevel = 'log', writeStreamType) {
|
|
70
80
|
if (this.printMessagesFunction) {
|
|
71
81
|
const call = this.printMessagesFunction(messages, context, logLevel, writeStreamType);
|
|
@@ -79,12 +89,20 @@ let RxapLogger = class RxapLogger extends common_1.ConsoleLogger {
|
|
|
79
89
|
}
|
|
80
90
|
};
|
|
81
91
|
exports.RxapLogger = RxapLogger;
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, common_1.Optional)(),
|
|
94
|
+
(0, common_1.Inject)(tokens_1.RXAP_LOGGER_PRINT_MESSAGES),
|
|
95
|
+
tslib_1.__metadata("design:type", Object)
|
|
96
|
+
], RxapLogger.prototype, "printMessagesFunction", void 0);
|
|
97
|
+
tslib_1.__decorate([
|
|
98
|
+
(0, common_1.Optional)(),
|
|
99
|
+
(0, common_1.Inject)(tokens_1.RXAP_LOGGER_FORMAT_MESSAGE),
|
|
100
|
+
tslib_1.__metadata("design:type", Object)
|
|
101
|
+
], RxapLogger.prototype, "formatMessageFunction", void 0);
|
|
82
102
|
exports.RxapLogger = RxapLogger = tslib_1.__decorate([
|
|
83
103
|
(0, common_1.Injectable)(),
|
|
84
104
|
tslib_1.__param(0, (0, common_1.Optional)()),
|
|
85
105
|
tslib_1.__param(1, (0, common_1.Inject)(tokens_1.CONSOLE_LOGGER_OPTIONS)),
|
|
86
106
|
tslib_1.__param(1, (0, common_1.Optional)()),
|
|
87
|
-
tslib_1.
|
|
88
|
-
tslib_1.__param(2, (0, common_1.Inject)(tokens_1.RXAP_LOGGER_PRINT_MESSAGES)),
|
|
89
|
-
tslib_1.__metadata("design:paramtypes", [String, Object, Object])
|
|
107
|
+
tslib_1.__metadata("design:paramtypes", [String, Object])
|
|
90
108
|
], RxapLogger);
|
package/src/lib/tokens.d.ts
CHANGED
package/src/lib/tokens.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RXAP_LOGGER_PRINT_MESSAGES = exports.CONSOLE_LOGGER_OPTIONS = void 0;
|
|
3
|
+
exports.RXAP_LOGGER_FORMAT_MESSAGE = exports.RXAP_LOGGER_PRINT_MESSAGES = exports.CONSOLE_LOGGER_OPTIONS = void 0;
|
|
4
4
|
exports.CONSOLE_LOGGER_OPTIONS = Symbol('CONSOLE_LOGGER_OPTIONS');
|
|
5
5
|
exports.RXAP_LOGGER_PRINT_MESSAGES = Symbol('RXAP_LOGGER_PRINT_MESSAGES');
|
|
6
|
+
exports.RXAP_LOGGER_FORMAT_MESSAGE = Symbol('RXAP_LOGGER_FORMAT_MESSAGE');
|