@infineit/winston-logger 1.0.23 → 1.0.25
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 +154 -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,154 @@
|
|
|
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
|
+
This project implements a production-ready logger for Nest.js applications using Winston and Morgan on a clean architecture (Hexagonal Architecture).
|
|
14
|
+
|
|
15
|
+
You can read a detailed explanation of the project on the following article: https://medium.com/p/d03e3bb56772/edit
|
|
16
|
+
|
|
17
|
+
That implements a production-ready system advanced or basic Microservices or Monoliths projects applying concepts like:
|
|
18
|
+
|
|
19
|
+
* Correlation IDs
|
|
20
|
+
* Decoupled log transporters
|
|
21
|
+
* Log levels
|
|
22
|
+
* Logging Rules
|
|
23
|
+
* Log formatters
|
|
24
|
+
|
|
25
|
+
## Project structure
|
|
26
|
+
|
|
27
|
+
The project is structured in a Nest.js monorepo.
|
|
28
|
+
|
|
29
|
+
The folder structure is as follows:
|
|
30
|
+
|
|
31
|
+
* **apps**: It contains the project's executable applications, in this case, the REST API.
|
|
32
|
+
* **api**: It contains the REST API developed with Nest.js.
|
|
33
|
+
* **libs**: It contains the project packages or Bounded Contexts on a DDD language.
|
|
34
|
+
* **shared**: It contains the code of the Shared Kernel.
|
|
35
|
+
* **src**: It contains the source code.
|
|
36
|
+
* **config**: It contains de config module.
|
|
37
|
+
* **context**: It contains the context module.
|
|
38
|
+
* **logger**: It contains the logger module.
|
|
39
|
+
|
|
40
|
+
## Key concepts
|
|
41
|
+
|
|
42
|
+
### Architecture
|
|
43
|
+
|
|
44
|
+
The project is structured on a Hexagonal Architecture, so it has the following layers:
|
|
45
|
+
|
|
46
|
+
* **Application**
|
|
47
|
+
* **Domain**
|
|
48
|
+
* **Infrastructure**
|
|
49
|
+
|
|
50
|
+
### Logging Libraries
|
|
51
|
+
|
|
52
|
+
We use Winston to manage the logs and Morgan to log the HTTP requests. All that is managed by the `LoggerModule`.
|
|
53
|
+
|
|
54
|
+
To manage Winston transports, we use the `WinstonLoggerTransportsKey` DI token that is defined on the `LoggerModule`.
|
|
55
|
+
|
|
56
|
+
### Decoupling Logging library
|
|
57
|
+
|
|
58
|
+
To decouple the Logging library from our domain, we have created a `Logger` interface that is implemented by the `WinstonLogger` class.
|
|
59
|
+
|
|
60
|
+
If we want to change the logging library, we only have to implement the `Logger` interface and update the dependecy on the `LoggerModule`.
|
|
61
|
+
|
|
62
|
+
### NestJS Logger
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
We pass that adapter to the NestJS app on the `main.ts` file.
|
|
67
|
+
|
|
68
|
+
### Correlation IDs
|
|
69
|
+
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
|
+
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.
|
|
73
|
+
|
|
74
|
+
### Context Wrapper
|
|
75
|
+
|
|
76
|
+
To add custom data to all the logs, we use a wrapper `LoggerContextWrapper`.
|
|
77
|
+
|
|
78
|
+
That class is injected with a Transient scope. By that, we can get the caller class and add it to the logs.
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
* Install dependencies
|
|
83
|
+
```sh
|
|
84
|
+
yarn install
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
* Copy file .env.example a .env
|
|
88
|
+
```sh
|
|
89
|
+
cp .env.example .env
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
* Start REST API
|
|
93
|
+
```sh
|
|
94
|
+
yarn start:dev api
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
* Test REST API
|
|
98
|
+
```sh
|
|
99
|
+
curl -X GET http://localhost:3000
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
* Test REST API with correlation ID
|
|
103
|
+
```sh
|
|
104
|
+
curl -X GET http://localhost:3000 -H "x-correlation-id: 87815cc5-d0f2-41e5-a731-ac55bbb733e8"
|
|
105
|
+
```
|
|
106
|
+
## Publish on npm
|
|
107
|
+
|
|
108
|
+
* Build file through nestjs-logger/libs/shared/src
|
|
109
|
+
```sh
|
|
110
|
+
yarn build
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
* got to nestjs-logger/dist/libs/nestjs
|
|
114
|
+
```sh
|
|
115
|
+
npm publish --access public
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Inspire by
|
|
119
|
+
|
|
120
|
+
* https://github.com/jnm733/nestjs-logger/tree/main
|
|
121
|
+
|
|
122
|
+
* https://medium.com/@jose-luis-navarro/logging-on-nestjs-like-a-pro-with-correlation-ids-log-aggregation-winston-morgan-and-more-d03e3bb56772
|
|
123
|
+
|
|
124
|
+
* https://github.com/InnovA2/winston-pg/tree/main
|
|
125
|
+
|
|
126
|
+
## Prisma Table
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
model winstonlog {
|
|
130
|
+
id_log String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
131
|
+
level String @db.VarChar(80)
|
|
132
|
+
message String @db.Text
|
|
133
|
+
context String? @db.VarChar(255)
|
|
134
|
+
correlationId String? @db.Uuid
|
|
135
|
+
sourceClass String? @db.VarChar(255)
|
|
136
|
+
props Json?
|
|
137
|
+
organization String? @db.VarChar(40)
|
|
138
|
+
app String? @db.VarChar(40)
|
|
139
|
+
durationMs Decimal? @default(0) @db.Decimal(10, 4)
|
|
140
|
+
stack String? @db.Text
|
|
141
|
+
label String? @db.VarChar(40)
|
|
142
|
+
timestamp DateTime @default(now()) @db.Timestamptz(6)
|
|
143
|
+
|
|
144
|
+
@@schema("public")
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## To do
|
|
149
|
+
|
|
150
|
+
We will continue working on this project to add new features
|
|
151
|
+
|
|
152
|
+
PRs are welcome!
|
|
153
|
+
|
|
154
|
+
- [ ] Add testing.
|
|
@@ -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,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M,EAAC,eAAQ,CAAC,CAAA;IAChB,WAAA,IAAA,eAAM,EAAC,gDAAwB,CAAC,CAAA;6DAEV,sBAAa;GAVvB,aAAa,CAsEjC;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,E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G,EAAE,GAAG,EAAE,EAAE;gBACxB,MAAM,UAAU,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;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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 -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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AC,CAAC;IACP,CAAC;IA+CO,MAAM,CAAC,QAAQ,CAAC,KAAgB,EAAE,OAAe;QACrD,OAAO,GAAG,KAAK,GAAG,OAAO,SAAS,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,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI;YACnC,aAAa,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa,IAAI,IAAI;YAC/C,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC;gBAC9C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;gBAClC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,IAAI,IAAI;YACpC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,IAAI;YAC/B,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,IAAI;YAC/B,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,IAAI;YAC/B,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,IAAI,CAAC;SACzC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,UAAU;aACjB,MAAM,CAAC;YACJ,IAAI,EAAE,OAAO;SAChB,CAAC;aACD,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;aACtB,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,GAAG,CAAC,CAAC;YAChE,QAAQ,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AAEQ,0CAAe"}
|
|
@@ -4,18 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const winston_slack_webhook_transport_1 = __importDefault(require("winston-slack-webhook-transport"));
|
|
7
|
-
const log_1 = require("
|
|
7
|
+
const log_1 = require("../../../../logger/domain/log");
|
|
8
8
|
class SlackTransport {
|
|
9
9
|
static create(webhookUrl) {
|
|
10
10
|
return new winston_slack_webhook_transport_1.default({
|
|
11
11
|
level: log_1.LogLevel.Fatal,
|
|
12
12
|
webhookUrl: webhookUrl,
|
|
13
13
|
formatter: (info) => {
|
|
14
|
-
const title = '[' +
|
|
15
|
-
info.timestamp +
|
|
16
|
-
'] Fatal error registered [' +
|
|
17
|
-
info.data.label +
|
|
18
|
-
']';
|
|
14
|
+
const title = '[' + info.timestamp + '] Fatal error registered [' + info.data.label + ']';
|
|
19
15
|
return {
|
|
20
16
|
text: title,
|
|
21
17
|
blocks: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slackTransport.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"slackTransport.js","sourceRoot":"","sources":["../../../../../../libs/src/logger/infrastructure/winston/transports/slackTransport.ts"],"names":[],"mappings":";;;;;AAAA,sGAAwD;AAExD,uDAAyD;AAEzD,MAAqB,cAAc;IACxB,MAAM,CAAC,MAAM,CAAC,UAAkB;QACnC,OAAO,IAAI,yCAAS,CAAC;YACjB,KAAK,EAAE,cAAQ,CAAC,KAAK;YACrB,UAAU,EAAE,UAAU;YACtB,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChB,MAAM,KAAK,GACP,GAAG,GAAG,IAAI,CAAC,SAAS,GAAG,4BAA4B,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;gBAChF,OAAO;oBACH,IAAI,EAAE,KAAK;oBACX,MAAM,EAAE;wBACJ;4BACI,IAAI,EAAE,SAAS;4BACf,MAAM,EAAE;gCACJ;oCACI,IAAI,EAAE,QAAQ;oCACd,IAAI,EAAE,GAAG,GAAG,KAAK,GAAG,GAAG;iCAC1B;6BACJ;yBACJ;wBACD;4BACI,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE;gCACF,IAAI,EAAE,QAAQ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