@infineit/winston-logger 1.0.23 → 1.0.26
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 +184 -0
- package/context/domain/interfaces/contextStorageService.d.ts +1 -1
- package/context/domain/interfaces/contextStorageService.js.map +1 -1
- package/context/infrastructure/nestjs/contextModule.js +5 -5
- package/context/infrastructure/nestjs/contextModule.js.map +1 -1
- package/context/infrastructure/nestjs-cls/nestjsClsContextStorageService.d.ts +1 -1
- package/context/infrastructure/nestjs-cls/nestjsClsContextStorageService.js +1 -1
- package/context/infrastructure/nestjs-cls/nestjsClsContextStorageService.js.map +1 -1
- package/index.d.ts +5 -0
- package/index.js +13 -0
- package/index.js.map +1 -0
- package/logger/domain/log.d.ts +0 -1
- package/logger/domain/log.js +1 -1
- package/logger/domain/log.js.map +1 -1
- package/logger/domain/logger.d.ts +1 -1
- package/logger/domain/logger.js.map +1 -1
- package/logger/domain/loggerService.d.ts +5 -4
- package/logger/domain/loggerService.js +10 -8
- package/logger/domain/loggerService.js.map +1 -1
- package/logger/infrastructure/nestjs/loggerModule.d.ts +1 -1
- package/logger/infrastructure/nestjs/loggerModule.js +13 -14
- package/logger/infrastructure/nestjs/loggerModule.js.map +1 -1
- package/logger/infrastructure/nestjs/nestjsLoggerServiceAdapter.d.ts +1 -1
- package/logger/infrastructure/nestjs/nestjsLoggerServiceAdapter.js.map +1 -1
- package/logger/infrastructure/winston/transports/consoleTransport.js +1 -1
- package/logger/infrastructure/winston/transports/consoleTransport.js.map +1 -1
- package/logger/infrastructure/winston/transports/fileTransport.js.map +1 -1
- package/logger/infrastructure/winston/transports/prisma-transport.d.ts +2 -2
- package/logger/infrastructure/winston/transports/prisma-transport.js +14 -6
- package/logger/infrastructure/winston/transports/prisma-transport.js.map +1 -1
- package/logger/infrastructure/winston/transports/slackTransport.js +2 -6
- package/logger/infrastructure/winston/transports/slackTransport.js.map +1 -1
- package/logger/infrastructure/winston/winstonLogger.d.ts +2 -2
- package/logger/infrastructure/winston/winstonLogger.js +2 -2
- package/logger/infrastructure/winston/winstonLogger.js.map +1 -1
- package/logger/levelFilter.js.map +1 -1
- package/package.json +27 -5
- package/tsconfig.lib.tsbuildinfo +1 -1
- package/config/domain/services/configService.d.ts +0 -0
- package/config/domain/services/configService.js +0 -1
- package/config/domain/services/configService.js.map +0 -1
- package/config/infrastructure/nestjs/configModule.d.ts +0 -0
- package/config/infrastructure/nestjs/configModule.js +0 -1
- package/config/infrastructure/nestjs/configModule.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<br />
|
|
2
|
+
<div align="center">
|
|
3
|
+
<h3 align="center">NestJS Logger</h3>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
A Nest.js production-ready logger implementation.
|
|
7
|
+
</p>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Introduction
|
|
12
|
+
|
|
13
|
+
`@infineit/winston-logger` is a lightweight project for implements a production-ready logger for Nest.js applications using Winston, Morgan and Prisma. This package simplifies the setup of logger and provides configurable options for instrumenting your application.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- **Easy Integration**: Quickly integrate logger with winston for distributed log.
|
|
19
|
+
- **Configurable**: Provides options to customize logger configuration.
|
|
20
|
+
- **Lightweight**: Minimal dependencies and overhead.
|
|
21
|
+
|
|
22
|
+
That implements a production-ready system advanced or basic Microservices or Monoliths projects applying concepts like:
|
|
23
|
+
|
|
24
|
+
* Correlation IDs
|
|
25
|
+
* Decoupled log transporters
|
|
26
|
+
* Log levels
|
|
27
|
+
* Logging Rules
|
|
28
|
+
* Log formatters
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
* You can install this package using npm:
|
|
33
|
+
```bash
|
|
34
|
+
npm install @infineit/winston-logger
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or using Yarn:
|
|
38
|
+
```bash
|
|
39
|
+
yarn add @infineit/winston-logger
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Basic Setup
|
|
46
|
+
|
|
47
|
+
To use `@infineit/winston-logger` in your NestJS application, simply import it of your `main.ts` file:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
import { NestjsLoggerServiceAdapter } from '@infineit/winston-logger';;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Prerequisites
|
|
54
|
+
|
|
55
|
+
- NestJS
|
|
56
|
+
- Winston
|
|
57
|
+
- morgon
|
|
58
|
+
- prisma
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Getting Started
|
|
62
|
+
|
|
63
|
+
Follow these steps to set up and run logger. If all steps are followed correctly, logger should start without any issues:
|
|
64
|
+
|
|
65
|
+
1. use logger after import in main.ts:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
const app = await NestFactory.create(AppModule, {bufferLogs: true });
|
|
69
|
+
|
|
70
|
+
app.useLogger(app.get(NestjsLoggerServiceAdapter));
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
2. import in app.module.ts:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
import { ContextModule, LoggerModule } from '@infineit/winston-logger';
|
|
77
|
+
|
|
78
|
+
@Module({
|
|
79
|
+
imports: [
|
|
80
|
+
ContextModule,
|
|
81
|
+
LoggerModule.forRoot(PrismaService),
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
3. app.service.ts:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
import Logger, { LoggerKey } from '@infineit/winston-logger';
|
|
90
|
+
|
|
91
|
+
constructor(@Inject(LoggerKey) private logger: Logger) {}
|
|
92
|
+
|
|
93
|
+
this.logger.info('I am an info message!', {
|
|
94
|
+
props: {
|
|
95
|
+
foo: 'bar',
|
|
96
|
+
baz: 'qux',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Reminder**: Make sure prisma is initialize and winstonlog modal is running before starting your NestJS application to avoid initialization errors.
|
|
102
|
+
|
|
103
|
+
## Configuration
|
|
104
|
+
|
|
105
|
+
You can configure the Logger using environment variables in your `.env` file:
|
|
106
|
+
|
|
107
|
+
- `NODE_ENV`: development / staging / testing / production.
|
|
108
|
+
- `LOGGER_ORGANIZATION`: The name of your organization as it will appear in log.
|
|
109
|
+
- `LOGGER_CONTEXT`: The name of your context as it will appear in log.
|
|
110
|
+
- `LOGGER_APP`: The name of your app as it will appear in log.
|
|
111
|
+
- `LOGGER_DATABASE_STORAGE`: True/False. Default True for production or testing, It will store log to database.
|
|
112
|
+
- `LOGGER_LOG_LEVEL`: Default log level warn,error,fatal for production or testing, It will log.
|
|
113
|
+
- `LOGGER_DURATION`: True/False. Default False, It will store request duration in database.
|
|
114
|
+
- `LOGGER_DURATION_LOG_LEVEL`: Default log level warn,error,fatal for production or testing, It will calculate duration for request.
|
|
115
|
+
- `LOGGER_CONSOLE_PRINT`: True/False. Default False for production or testing.
|
|
116
|
+
- `LOGGER_LOG_IN_FILE`: True/False. Default False for production or testing.
|
|
117
|
+
- `LOGGER_SLACK_INC_WEBHOOK_URL`: Slack url, eg. https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX.
|
|
118
|
+
|
|
119
|
+
## Project structure
|
|
120
|
+
|
|
121
|
+
## Key concepts
|
|
122
|
+
|
|
123
|
+
### NestJS Logger
|
|
124
|
+
|
|
125
|
+
NestJS uses a custom logger for bootstrap and internal logging. To use our logger, we need to create an adapter that implements the NestJS `LoggerService` interface. That is implemented in the `NestjsLoggerServiceAdapter` class.
|
|
126
|
+
|
|
127
|
+
We pass that adapter to the NestJS app on the `main.ts` file.
|
|
128
|
+
|
|
129
|
+
### Correlation IDs
|
|
130
|
+
|
|
131
|
+
To manage correlation IDs, we use `nestjs-cls` library that implements a Local Storage. With that, we can isolate and share data on a request lifecycle.
|
|
132
|
+
|
|
133
|
+
The system reads the `x-correlation-id` HTTP header and stores it on the Local Storage. If the header is not present, the system generates a new UUID and stores it on the Local Storage.
|
|
134
|
+
|
|
135
|
+
### Context Wrapper
|
|
136
|
+
|
|
137
|
+
To add custom data to all the logs, we use a wrapper `LoggerContextWrapper`.
|
|
138
|
+
|
|
139
|
+
That class is injected with a Transient scope. By that, we can get the caller class and add it to the logs.
|
|
140
|
+
|
|
141
|
+
## Prisma Table
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
model winstonlog {
|
|
145
|
+
id_log String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
146
|
+
level String @db.VarChar(80)
|
|
147
|
+
message String @db.Text
|
|
148
|
+
context String? @db.VarChar(255)
|
|
149
|
+
correlationId String? @db.Uuid
|
|
150
|
+
sourceClass String? @db.VarChar(255)
|
|
151
|
+
props Json?
|
|
152
|
+
organization String? @db.VarChar(40)
|
|
153
|
+
app String? @db.VarChar(40)
|
|
154
|
+
durationMs Decimal? @default(0) @db.Decimal(10, 4)
|
|
155
|
+
stack String? @db.Text
|
|
156
|
+
label String? @db.VarChar(40)
|
|
157
|
+
timestamp DateTime @default(now()) @db.Timestamptz(6)
|
|
158
|
+
|
|
159
|
+
@@schema("public")
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
## Inspiration
|
|
163
|
+
|
|
164
|
+
This project is inspired by the excellent work from:
|
|
165
|
+
|
|
166
|
+
- [Medium](https://medium.com/@jose-luis-navarro/logging-on-nestjs-like-a-pro-with-correlation-ids-log-aggregation-winston-morgan-and-more-d03e3bb56772)
|
|
167
|
+
- [Logger GitHub Repository](https://github.com/SigNoz/signoz)
|
|
168
|
+
- [winston-pg GitHub Repository](https://github.com/InnovA2/winston-pg/tree/main)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
## Support
|
|
172
|
+
|
|
173
|
+
NestJS is an MIT-licensed open-source project that thrives with support from the community. If you’d like to contribute or sponsor, please [learn more here](https://docs.nestjs.com/support).
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
|
|
178
|
+
|
|
179
|
+
## Author
|
|
180
|
+
|
|
181
|
+
Dharmesh Patel 🇮🇳 <br>
|
|
182
|
+
- [GitHub](https://github.com/dharmesh-r-patel/nestjs-starter)
|
|
183
|
+
- [LinkedIn](https://www.linkedin.com/in/dharmeshbbay)
|
|
184
|
+
- [Instagram](https://www.instagram.com/dharmesh_numbertank)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const ContextStorageServiceKey: unique symbol;
|
|
2
2
|
export default interface ContextStorageService {
|
|
3
3
|
setContextId(contextId: string): void;
|
|
4
|
-
getContextId(): string;
|
|
4
|
+
getContextId(): string | undefined;
|
|
5
5
|
get<T>(key: string): T | undefined;
|
|
6
6
|
set<T>(key: string, value: T): void;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextStorageService.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"contextStorageService.js","sourceRoot":"","sources":["../../../../../libs/src/context/domain/interfaces/contextStorageService.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,MAAM,EAAE,CAAC"}
|
|
@@ -11,13 +11,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ContextModule = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
-
const uuid_1 = require("uuid");
|
|
15
14
|
const nestjs_cls_1 = require("nestjs-cls");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
15
|
+
const uuid_1 = require("uuid");
|
|
16
|
+
const contextStorageService_1 = require("../../../context/domain/interfaces/contextStorageService");
|
|
17
|
+
const nestjsClsContextStorageService_1 = __importDefault(require("../../../context/infrastructure/nestjs-cls/nestjsClsContextStorageService"));
|
|
18
18
|
let ContextModule = class ContextModule {
|
|
19
19
|
};
|
|
20
|
-
ContextModule =
|
|
20
|
+
exports.ContextModule = ContextModule;
|
|
21
|
+
exports.ContextModule = ContextModule = __decorate([
|
|
21
22
|
(0, common_1.Global)(),
|
|
22
23
|
(0, common_1.Module)({
|
|
23
24
|
imports: [
|
|
@@ -40,5 +41,4 @@ ContextModule = __decorate([
|
|
|
40
41
|
exports: [contextStorageService_1.ContextStorageServiceKey],
|
|
41
42
|
})
|
|
42
43
|
], ContextModule);
|
|
43
|
-
exports.ContextModule = ContextModule;
|
|
44
44
|
//# sourceMappingURL=contextModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextModule.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"contextModule.js","sourceRoot":"","sources":["../../../../../libs/src/context/infrastructure/nestjs/contextModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgD;AAEhD,2CAAuC;AACvC,+BAA0B;AAE1B,oGAAoG;AACpG,+IAAuH;AAuBhH,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IArBzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE;YACL,sBAAS,CAAC,OAAO,CAAC;gBACd,MAAM,EAAE,IAAI;gBACZ,UAAU,EAAE;oBACR,KAAK,EAAE,IAAI;oBACX,UAAU,EAAE,IAAI;oBAChB,WAAW,EAAE,CAAC,GAAY,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,IAAA,SAAE,GAAE;iBACzE;aACJ,CAAC;SACL;QACD,WAAW,EAAE,EAAE;QACf,SAAS,EAAE;YACP;gBACI,OAAO,EAAE,gDAAwB;gBACjC,QAAQ,EAAE,wCAA8B;aAC3C;SACJ;QACD,OAAO,EAAE,CAAC,gDAAwB,CAAC;KACtC,CAAC;GACW,aAAa,CAAG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ContextStorageService from '@infineit/winston-logger/context/domain/interfaces/contextStorageService';
|
|
2
1
|
import { ClsService } from 'nestjs-cls';
|
|
2
|
+
import ContextStorageService from '../../../context/domain/interfaces/contextStorageService';
|
|
3
3
|
export default class NestjsClsContextStorageService implements ContextStorageService {
|
|
4
4
|
private readonly cls;
|
|
5
5
|
constructor(cls: ClsService);
|
|
@@ -9,8 +9,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const nestjs_cls_1 = require("nestjs-cls");
|
|
13
12
|
const common_1 = require("@nestjs/common");
|
|
13
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
14
14
|
let NestjsClsContextStorageService = class NestjsClsContextStorageService {
|
|
15
15
|
cls;
|
|
16
16
|
constructor(cls) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestjsClsContextStorageService.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"nestjsClsContextStorageService.js","sourceRoot":"","sources":["../../../../../libs/src/context/infrastructure/nestjs-cls/nestjsClsContextStorageService.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAA4C;AAE5C,2CAAgD;AAKjC,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAClB;IAA7B,YAA6B,GAAe;QAAf,QAAG,GAAH,GAAG,CAAY;IAAG,CAAC;IAEzC,GAAG,CAAI,GAAW;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAEM,YAAY,CAAC,EAAU;QAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,mBAAM,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAEM,GAAG,CAAI,GAAW,EAAE,KAAQ;QAC/B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAA;AAlBoB,8BAA8B;IADlD,IAAA,mBAAU,GAAE;qCAEyB,uBAAU;GAD3B,8BAA8B,CAkBlD;kBAlBoB,8BAA8B"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ContextModule } from './context/infrastructure/nestjs/contextModule';
|
|
2
|
+
import { LoggerModule } from './logger/infrastructure/nestjs/loggerModule';
|
|
3
|
+
import NestjsLoggerServiceAdapter from './logger/infrastructure/nestjs/nestjsLoggerServiceAdapter';
|
|
4
|
+
export { NestjsLoggerServiceAdapter };
|
|
5
|
+
export { ContextModule, LoggerModule };
|
package/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LoggerModule = exports.ContextModule = exports.NestjsLoggerServiceAdapter = void 0;
|
|
7
|
+
const contextModule_1 = require("./context/infrastructure/nestjs/contextModule");
|
|
8
|
+
Object.defineProperty(exports, "ContextModule", { enumerable: true, get: function () { return contextModule_1.ContextModule; } });
|
|
9
|
+
const loggerModule_1 = require("./logger/infrastructure/nestjs/loggerModule");
|
|
10
|
+
Object.defineProperty(exports, "LoggerModule", { enumerable: true, get: function () { return loggerModule_1.LoggerModule; } });
|
|
11
|
+
const nestjsLoggerServiceAdapter_1 = __importDefault(require("./logger/infrastructure/nestjs/nestjsLoggerServiceAdapter"));
|
|
12
|
+
exports.NestjsLoggerServiceAdapter = nestjsLoggerServiceAdapter_1.default;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../libs/src/index.ts"],"names":[],"mappings":";;;;;;AAGA,iFAA8E;AASrE,8FATA,6BAAa,OASA;AARtB,8EAA2E;AAQnD,6FARf,2BAAY,OAQe;AANpC,2HAAmG;AAG1F,qCAHF,oCAA0B,CAGE"}
|
package/logger/domain/log.d.ts
CHANGED
package/logger/domain/log.js
CHANGED
package/logger/domain/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../libs/src/logger/domain/log.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAOX;AAPD,WAAY,QAAQ;IAChB,mCAAuB,CAAA;IACvB,2BAAe,CAAA;IACf,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACnB,CAAC,EAPW,QAAQ,wBAAR,QAAQ,QAOnB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogData, LogLevel } from '
|
|
1
|
+
import { LogData, LogLevel } from '../../logger/domain/log';
|
|
2
2
|
export declare const LoggerBaseKey: unique symbol;
|
|
3
3
|
export declare const LoggerKey: unique symbol;
|
|
4
4
|
export default interface Logger {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../libs/src/logger/domain/logger.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAG,MAAM,EAAE,CAAC;AACzB,QAAA,SAAS,GAAG,MAAM,EAAE,CAAC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
|
-
import
|
|
3
|
-
import { LogData, LogLevel } from '
|
|
4
|
-
import
|
|
2
|
+
import ContextStorageService from '../../context/domain/interfaces/contextStorageService';
|
|
3
|
+
import { LogData, LogLevel } from '../../logger/domain/log';
|
|
4
|
+
import Logger from '../../logger/domain/logger';
|
|
5
5
|
export default class LoggerService implements Logger {
|
|
6
6
|
private logger;
|
|
7
7
|
private contextStorageService;
|
|
8
|
+
private configService;
|
|
8
9
|
private sourceClass;
|
|
9
10
|
private organization;
|
|
10
11
|
private context;
|
|
11
12
|
private app;
|
|
12
|
-
constructor(logger: Logger,
|
|
13
|
+
constructor(logger: Logger, parentClass: object, contextStorageService: ContextStorageService, configService: ConfigService);
|
|
13
14
|
log(level: LogLevel, message: string | Error, data?: LogData, profile?: string): void;
|
|
14
15
|
debug(message: string, data?: LogData, profile?: string): void;
|
|
15
16
|
info(message: string, data?: LogData, profile?: string): void;
|
|
@@ -13,22 +13,24 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const common_1 = require("@nestjs/common");
|
|
16
|
-
const core_1 = require("@nestjs/core");
|
|
17
16
|
const config_1 = require("@nestjs/config");
|
|
18
|
-
const
|
|
19
|
-
const contextStorageService_1 = require("
|
|
17
|
+
const core_1 = require("@nestjs/core");
|
|
18
|
+
const contextStorageService_1 = require("../../context/domain/interfaces/contextStorageService");
|
|
19
|
+
const logger_1 = require("../../logger/domain/logger");
|
|
20
20
|
let LoggerService = class LoggerService {
|
|
21
21
|
logger;
|
|
22
22
|
contextStorageService;
|
|
23
|
+
configService;
|
|
23
24
|
sourceClass;
|
|
24
25
|
organization;
|
|
25
26
|
context;
|
|
26
27
|
app;
|
|
27
|
-
constructor(logger,
|
|
28
|
+
constructor(logger, parentClass, contextStorageService, configService) {
|
|
28
29
|
this.logger = logger;
|
|
29
30
|
this.contextStorageService = contextStorageService;
|
|
31
|
+
this.configService = configService;
|
|
30
32
|
this.sourceClass = parentClass?.constructor?.name;
|
|
31
|
-
const config = configService.getOrThrow('logger', {
|
|
33
|
+
const config = this.configService.getOrThrow('logger', {
|
|
32
34
|
infer: true,
|
|
33
35
|
});
|
|
34
36
|
this.organization = config.organization;
|
|
@@ -73,9 +75,9 @@ let LoggerService = class LoggerService {
|
|
|
73
75
|
LoggerService = __decorate([
|
|
74
76
|
(0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT }),
|
|
75
77
|
__param(0, (0, common_1.Inject)(logger_1.LoggerBaseKey)),
|
|
76
|
-
__param(
|
|
77
|
-
__param(
|
|
78
|
-
__metadata("design:paramtypes", [Object,
|
|
78
|
+
__param(1, (0, common_1.Inject)(core_1.INQUIRER)),
|
|
79
|
+
__param(2, (0, common_1.Inject)(contextStorageService_1.ContextStorageServiceKey)),
|
|
80
|
+
__metadata("design:paramtypes", [Object, Object, Object, config_1.ConfigService])
|
|
79
81
|
], LoggerService);
|
|
80
82
|
exports.default = LoggerService;
|
|
81
83
|
//# sourceMappingURL=loggerService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggerService.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"loggerService.js","sourceRoot":"","sources":["../../../../libs/src/logger/domain/loggerService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAA2D;AAC3D,2CAA+C;AAC/C,uCAAwC;AAExC,iGAE+D;AAE/D,uDAAmE;AAGpD,IAAM,aAAa,GAAnB,MAAM,aAAa;IAMK;IAGvB;IACA;IATJ,WAAW,CAAS;IACpB,YAAY,CAAS;IACrB,OAAO,CAAS;IAChB,GAAG,CAAS;IACpB,YACmC,MAAc,EAC3B,WAAmB,EAE7B,qBAA4C,EAC5C,aAA4B;QAJL,WAAM,GAAN,MAAM,CAAQ;QAGrC,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAAa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C;kBAtEoB,aAAa"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MiddlewareConsumer, NestModule, DynamicModule, InjectionToken } from '@nestjs/common';
|
|
2
|
-
import Logger from '@infineit/winston-logger/logger/domain/logger';
|
|
3
2
|
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import Logger from '../../../logger/domain/logger';
|
|
4
4
|
export declare class LoggerModule implements NestModule {
|
|
5
5
|
private logger;
|
|
6
6
|
private configService;
|
|
@@ -41,17 +41,17 @@ var LoggerModule_1;
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.LoggerModule = void 0;
|
|
43
43
|
const common_1 = require("@nestjs/common");
|
|
44
|
-
const winstonLogger_1 = __importStar(require("@infineit/winston-logger/logger/infrastructure/winston/winstonLogger"));
|
|
45
|
-
const logger_1 = require("@infineit/winston-logger/logger/domain/logger");
|
|
46
|
-
const nestjsLoggerServiceAdapter_1 = __importDefault(require("@infineit/winston-logger/logger/infrastructure/nestjs/nestjsLoggerServiceAdapter"));
|
|
47
|
-
const slackTransport_1 = __importDefault(require("@infineit/winston-logger/logger/infrastructure/winston/transports/slackTransport"));
|
|
48
|
-
const consoleTransport_1 = __importDefault(require("@infineit/winston-logger/logger/infrastructure/winston/transports/consoleTransport"));
|
|
49
|
-
const morgan_1 = __importDefault(require("morgan"));
|
|
50
|
-
const fileTransport_1 = __importDefault(require("@infineit/winston-logger/logger/infrastructure/winston/transports/fileTransport"));
|
|
51
|
-
const prisma_transport_1 = require("@infineit/winston-logger/logger/infrastructure/winston/transports/prisma-transport");
|
|
52
44
|
const config_1 = require("@nestjs/config");
|
|
53
|
-
const
|
|
54
|
-
const
|
|
45
|
+
const morgan_1 = __importDefault(require("morgan"));
|
|
46
|
+
const logger_1 = require("../../../logger/domain/logger");
|
|
47
|
+
const loggerService_1 = __importDefault(require("../../../logger/domain/loggerService"));
|
|
48
|
+
const nestjsLoggerServiceAdapter_1 = __importDefault(require("../../../logger/infrastructure/nestjs/nestjsLoggerServiceAdapter"));
|
|
49
|
+
const consoleTransport_1 = __importDefault(require("../../../logger/infrastructure/winston/transports/consoleTransport"));
|
|
50
|
+
const fileTransport_1 = __importDefault(require("../../../logger/infrastructure/winston/transports/fileTransport"));
|
|
51
|
+
const prisma_transport_1 = require("../../../logger/infrastructure/winston/transports/prisma-transport");
|
|
52
|
+
const slackTransport_1 = __importDefault(require("../../../logger/infrastructure/winston/transports/slackTransport"));
|
|
53
|
+
const winstonLogger_1 = __importStar(require("../../../logger/infrastructure/winston/winstonLogger"));
|
|
54
|
+
const levelFilter_1 = require("../../../logger/levelFilter");
|
|
55
55
|
let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
56
56
|
logger;
|
|
57
57
|
configService;
|
|
@@ -84,8 +84,7 @@ let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
|
84
84
|
const slackWebhookUrl = config.slack_webhook;
|
|
85
85
|
const databaseStorageConfig = config.database_storage;
|
|
86
86
|
const databaseStorage = databaseStorageConfig !== undefined
|
|
87
|
-
? databaseStorageConfig === 'true' ||
|
|
88
|
-
databaseStorageConfig === true
|
|
87
|
+
? databaseStorageConfig === 'true' || databaseStorageConfig === true
|
|
89
88
|
: false;
|
|
90
89
|
const loggingLevels = config.database_log_level || 'warn,error,fatal';
|
|
91
90
|
const levels = loggingLevels.split(',');
|
|
@@ -151,11 +150,11 @@ let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
152
|
};
|
|
154
|
-
LoggerModule =
|
|
153
|
+
exports.LoggerModule = LoggerModule;
|
|
154
|
+
exports.LoggerModule = LoggerModule = LoggerModule_1 = __decorate([
|
|
155
155
|
(0, common_1.Global)(),
|
|
156
156
|
(0, common_1.Module)({}),
|
|
157
157
|
__param(0, (0, common_1.Inject)(logger_1.LoggerKey)),
|
|
158
158
|
__metadata("design:paramtypes", [Object, config_1.ConfigService])
|
|
159
159
|
], LoggerModule);
|
|
160
|
-
exports.LoggerModule = LoggerModule;
|
|
161
160
|
//# sourceMappingURL=loggerModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggerModule.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"loggerModule.js","sourceRoot":"","sources":["../../../../../libs/src/logger/infrastructure/nestjs/loggerModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,2CAA+C;AAE/C,oDAA4B;AAE5B,0DAAiF;AACjF,yFAAiE;AACjE,kIAA0G;AAC1G,0HAAkG;AAClG,oHAA4F;AAC5F,yGAAqG;AACrG,sHAA8F;AAE9F,sGAE8D;AAC9D,6DAA0D;AAInD,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAmFU;IACnB;IAnFZ,MAAM,CAAC,OAAO,CAAC,kBAAkC;QAC7C,OAAO;YACH,MAAM,EAAE,cAAY;YACpB,SAAS,EAAE;gBACP;oBACI,OAAO,EAAE,sBAAa;oBACtB,QAAQ,EAAE,uBAAa;iBAC1B;gBACD;oBACI,OAAO,EAAE,kBAAS;oBAClB,QAAQ,EAAE,uBAAa;iBAC1B;gBACD;oBACI,OAAO,EAAE,oCAA0B;oBACnC,UAAU,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,oCAA0B,CAAC,MAAM,CAAC;oBACtE,MAAM,EAAE,CAAC,kBAAS,CAAC;iBACtB;gBACD;oBACI,OAAO,EAAE,0CAA0B;oBACnC,UAAU,EAAE,CAAC,aAA4B,EAAE,MAAW,EAAE,EAAE;wBACtD,MAAM,UAAU,GAAG,EAAE,CAAC;wBAEtB,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE;4BAC9C,KAAK,EAAE,IAAI;yBACd,CAAQ,CAAC;wBAEV,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,KAAK,YAAY,CAAC;wBACrD,MAAM,SAAS,G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gBACrD,MAAM,QAAQ,GAAG,gBAAgB,IAAI,MAAM,CAAC;gBAM5C,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;gBAErE,MAAM,OAAO,GAAQ;oBACjB,WAAW,EAAE,eAAe;oBAC5B,UAAU,EAAE,UAAU;iBACzB,CAAC;gBAEF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC5C,OAAO,OAAO,CAAC;YACnB,CAAC,CAAC,CACL;iBACA,SAAS,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IAyBL,CAAC;CACJ,CAAA;AAtJY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;IAoFF,WAAA,IAAA,eAAM,EAAC,kBAAS,CAAC,CAAA;6CACK,sBAAa;GApF/B,YAAY,CAsJxB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConsoleLogger } from '@nestjs/common';
|
|
2
|
-
import Logger from '@infineit/winston-logger/logger/domain/logger';
|
|
3
2
|
import { LoggerService } from '@nestjs/common/services/logger.service';
|
|
3
|
+
import Logger from '../../../logger/domain/logger';
|
|
4
4
|
export default class NestjsLoggerServiceAdapter extends ConsoleLogger implements LoggerService {
|
|
5
5
|
private logger;
|
|
6
6
|
constructor(logger: Logger);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestjsLoggerServiceAdapter.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"nestjsLoggerServiceAdapter.js","sourceRoot":"","sources":["../../../../../libs/src/logger/infrastructure/nestjs/nestjsLoggerServiceAdapter.ts"],"names":[],"mappings":";;AAAA,2CAA+C;AAK/C,MAAqB,0BAA2B,SAAQ,sBAAa;IACtC;IAA3B,YAA2B,MAAc;QACrC,KAAK,EAAE,CAAC;QADe,WAAM,GAAN,MAAM,CAAQ;IAEzC,CAAC;IAEM,GAAG,CAAC,OAAY,EAAE,GAAG,cAAqB;QAC7C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,OAAY,EAAE,GAAG,cAAqB;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;IACvE,CAAC;IAEM,IAAI,CAAC,OAAY,EAAE,GAAG,cAAqB;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,OAAY,EAAE,GAAG,cAAqB;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;IACvE,CAAC;IAEM,OAAO,CAAC,OAAY,EAAE,GAAG,cAAqB;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;IACtE,CAAC;IAEO,UAAU,CAAC,GAAG,cAAqB;QACvC,OAAO;YACH,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;SACjE,CAAC;IACN,CAAC;CACJ;AA9BD,6CA8BC"}
|
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const winston = __importStar(require("winston"));
|
|
27
|
-
const log_1 = require("
|
|
27
|
+
const log_1 = require("../../../../logger/domain/log");
|
|
28
28
|
var LogColors;
|
|
29
29
|
(function (LogColors) {
|
|
30
30
|
LogColors["red"] = "\u001B[31m";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleTransport.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"consoleTransport.js","sourceRoot":"","sources":["../../../../../../libs/src/logger/infrastructure/winston/transports/consoleTransport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,uDAAyD;AAEzD,IAAK,SAQJ;AARD,WAAK,SAAS;IACV,+BAAgB,CAAA;IAChB,iCAAkB,CAAA;IAClB,kCAAmB,CAAA;IACnB,gCAAiB,CAAA;IACjB,mCAAoB,CAAA;IACpB,gCAAiB,CAAA;IACjB,sCAAuB,CAAA;AAC3B,CAAC,EARI,SAAS,KAAT,SAAS,QAQb;AAED,MAAqB,gBAAgB;IAC1B,MAAM,CAAC,cAAc;QACxB,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAE1B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;gBAE1B,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAiB,CAAC,CAAC;gBAC3D,MAAM,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;gBAChE,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,KAC1C,GAAG,CAAC,SACR,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,G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S,CAAC;IACvC,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,KAAe;QAC3C,QAAQ,KAAK,EAAE,CAAC;YACZ,KAAK,cAAQ,CAAC,KAAK;gBACf,OAAO,SAAS,CAAC,IAAI,CAAC;YAC1B,KAAK,cAAQ,CAAC,IAAI;gBACd,OAAO,SAAS,CAAC,KAAK,CAAC;YAC3B,KAAK,cAAQ,CAAC,IAAI;gBACd,OAAO,SAAS,CAAC,MAAM,CAAC;YAC5B,KAAK,cAAQ,CAAC,KAAK;gBACf,OAAO,SAAS,CAAC,GAAG,CAAC;YACzB,KAAK,cAAQ,CAAC,KAAK;gBACf,OAAO,SAAS,CAAC,OAAO,CAAC;YAC7B,KAAK,cAAQ,CAAC,SAAS;gBACnB,OAAO,SAAS,CAAC,IAAI,CAAC;YAC1B;gBACI,OAAO,SAAS,CAAC,IAAI,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ;AArGD,mCAqGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileTransport.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"fileTransport.js","sourceRoot":"","sources":["../../../../../../libs/src/logger/infrastructure/winston/transports/fileTransport.ts"],"names":[],"mappings":";;AAAA,6DAA8D;AAE9D,MAAqB,aAAa;IACvB,MAAM,CAAC,MAAM;QAChB,OAAO,IAAI,eAAe,CAAC;YACvB,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,eAAe;YAC5B,aAAa,EAAE,IAAI;YACnB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;SAClB,CAAC,CAAC;IACP,CAAC;CACJ;AAXD,gCAWC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import TransportStream, { TransportStreamOptions } from 'winston-transport';
|
|
2
1
|
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
import Transport, { TransportStreamOptions } from 'winston-transport';
|
|
3
3
|
interface PrismaTransportOptions extends TransportStreamOptions {
|
|
4
4
|
prisma: PrismaClient;
|
|
5
5
|
}
|
|
6
|
-
declare class PrismaTransport extends
|
|
6
|
+
declare class PrismaTransport extends Transport {
|
|
7
7
|
private prisma;
|
|
8
8
|
constructor(options: PrismaTransportOptions);
|
|
9
9
|
log(info: any, callback: () => void): void;
|
|
@@ -12,26 +12,34 @@ class PrismaTransport extends winston_transport_1.default {
|
|
|
12
12
|
this.prisma = options.prisma;
|
|
13
13
|
}
|
|
14
14
|
log(info, callback) {
|
|
15
|
-
console.log("PRISMA TRANSPORT INFo---------------------------------", info);
|
|
16
15
|
setImmediate(() => this.emit('logged', info));
|
|
16
|
+
const timestamp = info.timestamp ? new Date(info.timestamp) : new Date();
|
|
17
|
+
const isValidDate = !isNaN(timestamp.getTime());
|
|
18
|
+
let valid_timestamp = new Date();
|
|
19
|
+
if (isValidDate) {
|
|
20
|
+
valid_timestamp = new Date(info.timestamp);
|
|
21
|
+
}
|
|
17
22
|
const logData = {
|
|
18
23
|
level: info.level,
|
|
19
24
|
message: info.message,
|
|
20
|
-
timestamp:
|
|
25
|
+
timestamp: valid_timestamp,
|
|
21
26
|
organization: info.data?.organization || null,
|
|
22
27
|
app: info.data?.app || null,
|
|
23
28
|
context: info.data?.context || null,
|
|
24
29
|
correlationId: info.data?.correlationId || null,
|
|
25
|
-
sourceClass: Array.isArray(info.data?.sourceClass)
|
|
30
|
+
sourceClass: Array.isArray(info.data?.sourceClass)
|
|
31
|
+
? info.data.sourceClass.join(', ')
|
|
32
|
+
: info.data?.sourceClass || null,
|
|
26
33
|
props: info.data?.props || null,
|
|
27
34
|
stack: info.data?.stack || null,
|
|
28
35
|
label: info.data?.label || null,
|
|
29
36
|
durationMs: info.data?.durationMs || 0,
|
|
30
37
|
};
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
this.prisma.winstonlog
|
|
39
|
+
.create({
|
|
33
40
|
data: logData,
|
|
34
|
-
})
|
|
41
|
+
})
|
|
42
|
+
.then(() => callback())
|
|
35
43
|
.catch((err) => {
|
|
36
44
|
console.error('Error logging [winstonlog] to PostgreSQL:', err);
|
|
37
45
|
callback();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-transport.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"prisma-transport.js","sourceRoot":"","sources":["../../../../../../libs/src/logger/infrastructure/winston/transports/prisma-transport.ts"],"names":[],"mappings":";;;;;;AACA,0EAAsE;AAMtE,MAAM,eAAgB,SAAQ,2BAAS;IAC3B,MAAM,CAAe;IAE7B,YAAY,OAA+B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,GAAG,CAAC,IAAS,EAAE,QAAoB;QAC/B,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAE9C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QACzE,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,IAAI,eAAe,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,IAAI,WAAW,EAAE,CAAC;YACd,eAAe,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,OAAO,GAAG;YACZ,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,eAAe;YAC1B,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,IAAI,IAAI;YAC7C,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,IAAI;YAC3B,O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