@infineit/winston-logger 1.0.29 → 1.0.31
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 +1229 -115
- package/context/infrastructure/nestjs/contextModule.js +2 -4
- package/context/infrastructure/nestjs/contextModule.js.map +1 -1
- package/index.d.ts +14 -5
- package/index.js +20 -5
- package/index.js.map +1 -1
- package/logger/domain/log.d.ts +3 -1
- package/logger/domain/loggerService.d.ts +7 -4
- package/logger/domain/loggerService.js +140 -31
- package/logger/domain/loggerService.js.map +1 -1
- package/logger/domain/loggerTransport.d.ts +5 -0
- package/logger/domain/loggerTransport.js +5 -0
- package/logger/domain/loggerTransport.js.map +1 -0
- package/logger/domain/normalizedLog.d.ts +23 -0
- package/logger/domain/normalizedLog.js +37 -0
- package/logger/domain/normalizedLog.js.map +1 -0
- package/logger/infrastructure/nestjs/loggerModule.d.ts +12 -9
- package/logger/infrastructure/nestjs/loggerModule.js +72 -137
- package/logger/infrastructure/nestjs/loggerModule.js.map +1 -1
- package/logger/infrastructure/nestjs/nestjsLoggerServiceAdapter.js +61 -11
- package/logger/infrastructure/nestjs/nestjsLoggerServiceAdapter.js.map +1 -1
- package/logger/infrastructure/winston/transports/fileTransport.d.ts +1 -1
- package/logger/infrastructure/winston/transports/fileTransport.js +5 -2
- package/logger/infrastructure/winston/transports/fileTransport.js.map +1 -1
- package/logger/infrastructure/winston/winstonLogger.js +78 -27
- package/logger/infrastructure/winston/winstonLogger.js.map +1 -1
- package/logger/infrastructure/winston/winstonTransportAdapter.d.ts +10 -0
- package/logger/infrastructure/winston/winstonTransportAdapter.js +128 -0
- package/logger/infrastructure/winston/winstonTransportAdapter.js.map +1 -0
- package/package.json +11 -16
- package/tsconfig.lib.tsbuildinfo +1 -1
- package/logger/infrastructure/winston/transports/prisma-transport.d.ts +0 -11
- package/logger/infrastructure/winston/transports/prisma-transport.js +0 -50
- package/logger/infrastructure/winston/transports/prisma-transport.js.map +0 -1
- package/logger/levelFilter.d.ts +0 -2
- package/logger/levelFilter.js +0 -47
- package/logger/levelFilter.js.map +0 -1
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ContextModule = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const nestjs_cls_1 = require("nestjs-cls");
|
|
15
|
-
const uuid_1 = require("uuid");
|
|
16
15
|
const contextStorageService_1 = require("../../../context/domain/interfaces/contextStorageService");
|
|
17
16
|
const nestjsClsContextStorageService_1 = __importDefault(require("../../../context/infrastructure/nestjs-cls/nestjsClsContextStorageService"));
|
|
18
17
|
let ContextModule = class ContextModule {
|
|
@@ -25,9 +24,8 @@ exports.ContextModule = ContextModule = __decorate([
|
|
|
25
24
|
nestjs_cls_1.ClsModule.forRoot({
|
|
26
25
|
global: true,
|
|
27
26
|
middleware: {
|
|
28
|
-
mount:
|
|
29
|
-
generateId:
|
|
30
|
-
idGenerator: (req) => req.headers['x-correlation-id'] ?? (0, uuid_1.v4)(),
|
|
27
|
+
mount: false,
|
|
28
|
+
generateId: false,
|
|
31
29
|
},
|
|
32
30
|
}),
|
|
33
31
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextModule.js","sourceRoot":"","sources":["../../../../../libs/src/context/infrastructure/nestjs/contextModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgD;AAEhD,2CAAuC;
|
|
1
|
+
{"version":3,"file":"contextModule.js","sourceRoot":"","sources":["../../../../../libs/src/context/infrastructure/nestjs/contextModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgD;AAEhD,2CAAuC;AAEvC,oGAAoG;AACpG,+IAAuH;AAsChH,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IAtBzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE;YAGL,sBAAS,CAAC,OAAO,CAAC;gBACd,MAAM,EAAE,IAAI;gBACZ,UAAU,EAAE;oBACR,KAAK,EAAE,KAAK;oBACZ,UAAU,EAAE,KAAK;iBACpB;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"}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { ContextModule } from './context/infrastructure/nestjs/contextModule';
|
|
2
|
+
export { LoggerModule, LoggerModuleConfig } from './logger/infrastructure/nestjs/loggerModule';
|
|
3
|
+
export { default as NestjsLoggerServiceAdapter } from './logger/infrastructure/nestjs/nestjsLoggerServiceAdapter';
|
|
4
|
+
export { LoggerKey } from './logger/domain/logger';
|
|
5
|
+
export type { default as Logger } from './logger/domain/logger';
|
|
6
|
+
export { default as LoggerService } from './logger/domain/loggerService';
|
|
7
|
+
export { ContextStorageServiceKey } from './context/domain/interfaces/contextStorageService';
|
|
8
|
+
export type { default as ContextStorageService } from './context/domain/interfaces/contextStorageService';
|
|
9
|
+
export { LoggerTransport, LoggerTransportKey } from './logger/domain/loggerTransport';
|
|
10
|
+
export type { NormalizedLog, SerializedError } from './logger/domain/normalizedLog';
|
|
11
|
+
export { serializeError } from './logger/domain/normalizedLog';
|
|
12
|
+
export { LogLevel } from './logger/domain/log';
|
|
13
|
+
export type { LogData, Log } from './logger/domain/log';
|
|
14
|
+
export { WinstonTransportAdapter, WinstonTransportAdapterTransportsKey, } from './logger/infrastructure/winston/winstonTransportAdapter';
|
package/index.js
CHANGED
|
@@ -3,11 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.WinstonTransportAdapterTransportsKey = exports.WinstonTransportAdapter = exports.LogLevel = exports.serializeError = exports.LoggerTransportKey = exports.ContextStorageServiceKey = exports.LoggerService = exports.LoggerKey = exports.NestjsLoggerServiceAdapter = exports.LoggerModule = exports.ContextModule = void 0;
|
|
7
|
+
var contextModule_1 = require("./context/infrastructure/nestjs/contextModule");
|
|
8
8
|
Object.defineProperty(exports, "ContextModule", { enumerable: true, get: function () { return contextModule_1.ContextModule; } });
|
|
9
|
-
|
|
9
|
+
var loggerModule_1 = require("./logger/infrastructure/nestjs/loggerModule");
|
|
10
10
|
Object.defineProperty(exports, "LoggerModule", { enumerable: true, get: function () { return loggerModule_1.LoggerModule; } });
|
|
11
|
-
|
|
12
|
-
exports
|
|
11
|
+
var nestjsLoggerServiceAdapter_1 = require("./logger/infrastructure/nestjs/nestjsLoggerServiceAdapter");
|
|
12
|
+
Object.defineProperty(exports, "NestjsLoggerServiceAdapter", { enumerable: true, get: function () { return __importDefault(nestjsLoggerServiceAdapter_1).default; } });
|
|
13
|
+
var logger_1 = require("./logger/domain/logger");
|
|
14
|
+
Object.defineProperty(exports, "LoggerKey", { enumerable: true, get: function () { return logger_1.LoggerKey; } });
|
|
15
|
+
var loggerService_1 = require("./logger/domain/loggerService");
|
|
16
|
+
Object.defineProperty(exports, "LoggerService", { enumerable: true, get: function () { return __importDefault(loggerService_1).default; } });
|
|
17
|
+
var contextStorageService_1 = require("./context/domain/interfaces/contextStorageService");
|
|
18
|
+
Object.defineProperty(exports, "ContextStorageServiceKey", { enumerable: true, get: function () { return contextStorageService_1.ContextStorageServiceKey; } });
|
|
19
|
+
var loggerTransport_1 = require("./logger/domain/loggerTransport");
|
|
20
|
+
Object.defineProperty(exports, "LoggerTransportKey", { enumerable: true, get: function () { return loggerTransport_1.LoggerTransportKey; } });
|
|
21
|
+
var normalizedLog_1 = require("./logger/domain/normalizedLog");
|
|
22
|
+
Object.defineProperty(exports, "serializeError", { enumerable: true, get: function () { return normalizedLog_1.serializeError; } });
|
|
23
|
+
var log_1 = require("./logger/domain/log");
|
|
24
|
+
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return log_1.LogLevel; } });
|
|
25
|
+
var winstonTransportAdapter_1 = require("./logger/infrastructure/winston/winstonTransportAdapter");
|
|
26
|
+
Object.defineProperty(exports, "WinstonTransportAdapter", { enumerable: true, get: function () { return winstonTransportAdapter_1.WinstonTransportAdapter; } });
|
|
27
|
+
Object.defineProperty(exports, "WinstonTransportAdapterTransportsKey", { enumerable: true, get: function () { return winstonTransportAdapter_1.WinstonTransportAdapterTransportsKey; } });
|
|
13
28
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../libs/src/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../libs/src/index.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA8E;AAArE,8GAAA,aAAa,OAAA;AACtB,4EAA+F;AAAtF,4GAAA,YAAY,OAAA;AACrB,wGAAkH;AAAzG,yJAAA,OAAO,OAA8B;AAE9C,iDAAmD;AAA1C,mGAAA,SAAS,OAAA;AAGlB,+DAAyE;AAAhE,+HAAA,OAAO,OAAiB;AAEjC,2FAA6F;AAApF,iIAAA,wBAAwB,OAAA;AAGjC,mEAAsF;AAA5D,qHAAA,kBAAkB,OAAA;AAE5C,+DAA+D;AAAtD,+GAAA,cAAc,OAAA;AAEvB,2CAA+C;AAAtC,+FAAA,QAAQ,OAAA;AAGjB,mGAGiE;AAF7D,kIAAA,uBAAuB,OAAA;AACvB,+IAAA,oCAAoC,OAAA"}
|
package/logger/domain/log.d.ts
CHANGED
|
@@ -12,12 +12,14 @@ export interface Log {
|
|
|
12
12
|
message: string;
|
|
13
13
|
data: LogData;
|
|
14
14
|
}
|
|
15
|
+
import { SerializedError } from './normalizedLog';
|
|
15
16
|
export interface LogData {
|
|
16
17
|
organization?: string;
|
|
17
18
|
context?: string;
|
|
18
19
|
app?: string;
|
|
19
20
|
sourceClass?: string;
|
|
20
21
|
correlationId?: string;
|
|
21
|
-
error?:
|
|
22
|
+
error?: SerializedError;
|
|
22
23
|
props?: NodeJS.Dict<any>;
|
|
24
|
+
durationMs?: number;
|
|
23
25
|
}
|
|
@@ -2,22 +2,25 @@ import { ConfigService } from '@nestjs/config';
|
|
|
2
2
|
import ContextStorageService from '../../context/domain/interfaces/contextStorageService';
|
|
3
3
|
import { LogData, LogLevel } from '../../logger/domain/log';
|
|
4
4
|
import Logger from '../../logger/domain/logger';
|
|
5
|
+
import { LoggerTransport } from '../../logger/domain/loggerTransport';
|
|
5
6
|
export default class LoggerService implements Logger {
|
|
6
|
-
private
|
|
7
|
+
private transports;
|
|
7
8
|
private contextStorageService;
|
|
8
9
|
private configService;
|
|
9
10
|
private sourceClass;
|
|
10
11
|
private organization;
|
|
11
12
|
private context;
|
|
12
13
|
private app;
|
|
13
|
-
constructor(
|
|
14
|
-
log(level: LogLevel, message: string | Error, data?: LogData,
|
|
14
|
+
constructor(transports: LoggerTransport[], parentClass: object, contextStorageService: ContextStorageService, configService: ConfigService);
|
|
15
|
+
log(level: LogLevel, message: string | Error, data?: LogData, _profile?: string): void;
|
|
15
16
|
debug(message: string, data?: LogData, profile?: string): void;
|
|
16
17
|
info(message: string, data?: LogData, profile?: string): void;
|
|
17
18
|
warn(message: string | Error, data?: LogData, profile?: string): void;
|
|
18
19
|
error(message: string | Error, data?: LogData, profile?: string): void;
|
|
19
20
|
fatal(message: string | Error, data?: LogData, profile?: string): void;
|
|
20
21
|
emergency(message: string | Error, data?: LogData, profile?: string): void;
|
|
22
|
+
startProfile(_id: string): void;
|
|
23
|
+
private normalizeLog;
|
|
24
|
+
private sendToTransports;
|
|
21
25
|
private getLogData;
|
|
22
|
-
startProfile(id: string): void;
|
|
23
26
|
}
|
|
@@ -16,68 +16,177 @@ const common_1 = require("@nestjs/common");
|
|
|
16
16
|
const config_1 = require("@nestjs/config");
|
|
17
17
|
const core_1 = require("@nestjs/core");
|
|
18
18
|
const contextStorageService_1 = require("../../context/domain/interfaces/contextStorageService");
|
|
19
|
-
const
|
|
19
|
+
const log_1 = require("../../logger/domain/log");
|
|
20
|
+
const loggerTransport_1 = require("../../logger/domain/loggerTransport");
|
|
21
|
+
const normalizedLog_1 = require("../../logger/domain/normalizedLog");
|
|
20
22
|
let LoggerService = class LoggerService {
|
|
21
|
-
|
|
23
|
+
transports;
|
|
22
24
|
contextStorageService;
|
|
23
25
|
configService;
|
|
24
26
|
sourceClass;
|
|
25
27
|
organization;
|
|
26
28
|
context;
|
|
27
29
|
app;
|
|
28
|
-
constructor(
|
|
29
|
-
this.
|
|
30
|
+
constructor(transports, parentClass, contextStorageService, configService) {
|
|
31
|
+
this.transports = transports;
|
|
30
32
|
this.contextStorageService = contextStorageService;
|
|
31
33
|
this.configService = configService;
|
|
32
34
|
this.sourceClass = parentClass?.constructor?.name;
|
|
33
|
-
|
|
34
|
-
infer: true
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
try {
|
|
36
|
+
const config = this.configService.get('logger', { infer: true });
|
|
37
|
+
this.organization = config?.organization;
|
|
38
|
+
this.context = config?.context;
|
|
39
|
+
this.app = config?.app;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
this.organization = undefined;
|
|
43
|
+
this.context = undefined;
|
|
44
|
+
this.app = undefined;
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
|
-
log(level, message, data,
|
|
41
|
-
|
|
47
|
+
log(level, message, data, _profile) {
|
|
48
|
+
try {
|
|
49
|
+
const normalizedLog = this.normalizeLog(level, message, data);
|
|
50
|
+
this.sendToTransports(normalizedLog);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error('LoggerService log error (swallowed):', error);
|
|
54
|
+
}
|
|
42
55
|
}
|
|
43
56
|
debug(message, data, profile) {
|
|
44
|
-
|
|
57
|
+
try {
|
|
58
|
+
this.log(log_1.LogLevel.Debug, message, data, profile);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error('LoggerService debug error (swallowed):', error);
|
|
62
|
+
}
|
|
45
63
|
}
|
|
46
64
|
info(message, data, profile) {
|
|
47
|
-
|
|
65
|
+
try {
|
|
66
|
+
this.log(log_1.LogLevel.Info, message, data, profile);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error('LoggerService info error (swallowed):', error);
|
|
70
|
+
}
|
|
48
71
|
}
|
|
49
72
|
warn(message, data, profile) {
|
|
50
|
-
|
|
73
|
+
try {
|
|
74
|
+
this.log(log_1.LogLevel.Warn, message, data, profile);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('LoggerService warn error (swallowed):', error);
|
|
78
|
+
}
|
|
51
79
|
}
|
|
52
80
|
error(message, data, profile) {
|
|
53
|
-
|
|
81
|
+
try {
|
|
82
|
+
this.log(log_1.LogLevel.Error, message, data, profile);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error('LoggerService error (swallowed):', error);
|
|
86
|
+
}
|
|
54
87
|
}
|
|
55
88
|
fatal(message, data, profile) {
|
|
56
|
-
|
|
89
|
+
try {
|
|
90
|
+
this.log(log_1.LogLevel.Fatal, message, data, profile);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.error('LoggerService fatal error (swallowed):', error);
|
|
94
|
+
}
|
|
57
95
|
}
|
|
58
96
|
emergency(message, data, profile) {
|
|
59
|
-
|
|
97
|
+
try {
|
|
98
|
+
this.log(log_1.LogLevel.Emergency, message, data, profile);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error('LoggerService emergency error (swallowed):', error);
|
|
102
|
+
}
|
|
60
103
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
104
|
+
startProfile(_id) {
|
|
105
|
+
try {
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
console.error('LoggerService startProfile error (swallowed):', error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
normalizeLog(level, message, data) {
|
|
112
|
+
try {
|
|
113
|
+
const logData = this.getLogData(data);
|
|
114
|
+
let error = logData?.error;
|
|
115
|
+
if (message instanceof Error) {
|
|
116
|
+
error = (0, normalizedLog_1.serializeError)(message);
|
|
117
|
+
}
|
|
118
|
+
else if (logData?.error) {
|
|
119
|
+
error =
|
|
120
|
+
logData.error instanceof Error ? (0, normalizedLog_1.serializeError)(logData.error) : logData.error;
|
|
121
|
+
}
|
|
122
|
+
const normalizedLog = {
|
|
123
|
+
timestamp: Date.now(),
|
|
124
|
+
level: level,
|
|
125
|
+
message: message instanceof Error ? message.message : message,
|
|
126
|
+
organization: logData?.organization,
|
|
127
|
+
context: logData?.context,
|
|
128
|
+
app: logData?.app,
|
|
129
|
+
sourceClass: logData?.sourceClass,
|
|
130
|
+
correlationId: logData?.correlationId,
|
|
131
|
+
error: error,
|
|
132
|
+
props: logData?.props,
|
|
133
|
+
durationMs: logData?.durationMs,
|
|
134
|
+
label: logData?.organization && logData?.context && logData?.app
|
|
135
|
+
? `${logData.organization}.${logData.context}.${logData.app}`
|
|
136
|
+
: undefined,
|
|
137
|
+
stack: error?.stack,
|
|
138
|
+
};
|
|
139
|
+
return normalizedLog;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.error('LoggerService normalizeLog error (swallowed):', error);
|
|
143
|
+
return {
|
|
144
|
+
timestamp: Date.now(),
|
|
145
|
+
level: level,
|
|
146
|
+
message: message instanceof Error ? message.message : String(message),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
70
149
|
}
|
|
71
|
-
|
|
72
|
-
|
|
150
|
+
sendToTransports(normalizedLog) {
|
|
151
|
+
try {
|
|
152
|
+
for (const transport of this.transports) {
|
|
153
|
+
try {
|
|
154
|
+
transport.log(normalizedLog);
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
console.error(`Transport error (swallowed):`, error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
console.error('LoggerService sendToTransports error (swallowed):', error);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
getLogData(data) {
|
|
166
|
+
try {
|
|
167
|
+
return {
|
|
168
|
+
...data,
|
|
169
|
+
organization: data?.organization || this.organization,
|
|
170
|
+
context: data?.context || this.context,
|
|
171
|
+
app: data?.app || this.app,
|
|
172
|
+
sourceClass: data?.sourceClass || this.sourceClass,
|
|
173
|
+
correlationId: data?.correlationId || this.contextStorageService.getContextId(),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
console.error('LoggerService getLogData error (swallowed):', error);
|
|
178
|
+
return {
|
|
179
|
+
...data,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
73
182
|
}
|
|
74
183
|
};
|
|
75
184
|
LoggerService = __decorate([
|
|
76
185
|
(0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT }),
|
|
77
|
-
__param(0, (0, common_1.Inject)(
|
|
186
|
+
__param(0, (0, common_1.Inject)(loggerTransport_1.LoggerTransportKey)),
|
|
78
187
|
__param(1, (0, common_1.Inject)(core_1.INQUIRER)),
|
|
79
188
|
__param(2, (0, common_1.Inject)(contextStorageService_1.ContextStorageServiceKey)),
|
|
80
|
-
__metadata("design:paramtypes", [
|
|
189
|
+
__metadata("design:paramtypes", [Array, Object, Object, config_1.ConfigService])
|
|
81
190
|
], LoggerService);
|
|
82
191
|
exports.default = LoggerService;
|
|
83
192
|
//# sourceMappingURL=loggerService.js.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAC/D,iDAA4D;AAE5D,yEAA0F;AAC1F,qEAAkF;AAGnE,IAAM,aAAa,GAAnB,MAAM,aAAa;IAMU;IAG5B;IACA;IATJ,WAAW,CAAS;IACpB,YAAY,CAAS;IACrB,OAAO,CAAS;IAChB,GAAG,CAAS;IACpB,YACwC,UAA6B,EAC/C,WAAmB,EAE7B,qBAA4C,EAC5C,aAA4B;QAJA,eAAU,GAAV,UAAU,CAAmB;QAGzD,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAAa,GAAb,aAAa,CAAe;QAGpC,IAAI,CAAC,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,IAAI,CAAC;QAElD,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAQ,CAAC;YACxE,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,YAAY,CAAC;YACzC,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,OAAO,CAAC;YAC/B,IAAI,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YAEL,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;YACzB,IAAI,CAAC,GAA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J,CAAA;AAhMoB,aAAa;IADjC,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,SAAS,EAAE,CAAC;IAO9B,WAAA,IAAA,eAAM,EAAC,oCAAkB,CAAC,CAAA;IAC1B,WAAA,IAAA,eAAM,EAAC,eAAQ,CAAC,CAAA;IAChB,WAAA,IAAA,eAAM,EAAC,gDAAwB,CAAC,CAAA;4DAEV,sBAAa;GAVvB,aAAa,CAgMjC;kBAhMoB,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggerTransport.js","sourceRoot":"","sources":["../../../../libs/src/logger/domain/loggerTransport.ts"],"names":[],"mappings":";;;AAKa,QAAA,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LogLevel } from './log';
|
|
2
|
+
export interface SerializedError {
|
|
3
|
+
name: string;
|
|
4
|
+
message: string;
|
|
5
|
+
stack?: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface NormalizedLog {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
level: LogLevel;
|
|
11
|
+
message: string;
|
|
12
|
+
organization?: string;
|
|
13
|
+
context?: string;
|
|
14
|
+
app?: string;
|
|
15
|
+
sourceClass?: string;
|
|
16
|
+
correlationId?: string;
|
|
17
|
+
error?: SerializedError;
|
|
18
|
+
props?: Record<string, any>;
|
|
19
|
+
durationMs?: number;
|
|
20
|
+
label?: string;
|
|
21
|
+
stack?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function serializeError(error: Error | unknown): SerializedError | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeError = serializeError;
|
|
4
|
+
function serializeError(error) {
|
|
5
|
+
if (!error) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
if (error instanceof Error) {
|
|
9
|
+
const serialized = {
|
|
10
|
+
name: error.name,
|
|
11
|
+
message: error.message,
|
|
12
|
+
};
|
|
13
|
+
if (error.stack) {
|
|
14
|
+
serialized.stack = error.stack;
|
|
15
|
+
}
|
|
16
|
+
Object.keys(error).forEach((key) => {
|
|
17
|
+
if (key !== 'name' && key !== 'message' && key !== 'stack') {
|
|
18
|
+
try {
|
|
19
|
+
serialized[key] = error[key];
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return serialized;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
return {
|
|
29
|
+
name: 'UnknownError',
|
|
30
|
+
message: String(error),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=normalizedLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizedLog.js","sourceRoot":"","sources":["../../../../libs/src/logger/domain/normalizedLog.ts"],"names":[],"mappings":";;AAoCA,wCAsCC;AAtCD,SAAgB,cAAc,CAAC,KAAsB;IACjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QACzB,MAAM,UAAU,GAAoB;YAChC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;SACzB,CAAC;QAEF,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACnC,CAAC;QAGD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;gBACzD,IAAI,CAAC;oBACD,UAAU,CAAC,GAAG,CAAC,GAAI,KAAa,CAAC,GAAG,CAAC,CAAC;gBAC1C,CAAC;gBAAC,MAAM,CAAC;gBAET,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC;IACtB,CAAC;IAGD,IAAI,CAAC;QACD,OAAO;YACH,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;SACzB,CAAC;IACN,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,SAAS,CAAC;IACrB,CAAC;AACL,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { DynamicModule, Provider } from '@nestjs/common';
|
|
2
|
+
export interface LoggerModuleConfig {
|
|
3
|
+
nodeEnv?: string;
|
|
4
|
+
slack_webhook?: string;
|
|
5
|
+
console_print?: boolean | string;
|
|
6
|
+
log_in_file?: boolean | string;
|
|
7
|
+
organization?: string;
|
|
8
|
+
context?: string;
|
|
9
|
+
app?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class LoggerModule {
|
|
12
|
+
static forRoot(config?: LoggerModuleConfig, additionalTransports?: Provider[]): DynamicModule;
|
|
10
13
|
}
|