@tc-libs/debugger 3.11.0 → 3.13.0
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/package.json +3 -2
- package/src/debugger.module.js +2 -0
- package/src/debugger.module.js.map +1 -1
- package/src/debugger.module.options.d.ts +11 -0
- package/src/interfaces/debugger.cloudwatch.transport.d.ts +30 -0
- package/src/interfaces/debugger.cloudwatch.transport.js +132 -0
- package/src/interfaces/debugger.cloudwatch.transport.js.map +1 -0
- package/src/services/debugger.service.d.ts +5 -1
- package/src/services/debugger.service.js +26 -2
- package/src/services/debugger.service.js.map +1 -1
- package/src/services/options/debugger.cloudwatch.options.service.d.ts +9 -0
- package/src/services/options/debugger.cloudwatch.options.service.js +73 -0
- package/src/services/options/debugger.cloudwatch.options.service.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tc-libs/debugger",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@tc-libs/errors": "3.
|
|
5
|
+
"@tc-libs/errors": "3.13.0",
|
|
6
6
|
"@nestjs/common": "^11.0.12",
|
|
7
|
+
"@aws-sdk/client-cloudwatch-logs": "^3.779.0",
|
|
7
8
|
"winston": "^3.17.0",
|
|
8
9
|
"winston-transport": "^4.9.0",
|
|
9
10
|
"telegraf": "^4.16.3",
|
package/src/debugger.module.js
CHANGED
|
@@ -6,10 +6,12 @@ const debugger_service_1 = require("./services/debugger.service");
|
|
|
6
6
|
const services_1 = require("./services");
|
|
7
7
|
const debugger_file_options_service_1 = require("./services/options/debugger.file.options.service");
|
|
8
8
|
const debugger_telegram_options_service_1 = require("./services/options/debugger.telegram.options.service");
|
|
9
|
+
const debugger_cloudwatch_options_service_1 = require("./services/options/debugger.cloudwatch.options.service");
|
|
9
10
|
const providers = [
|
|
10
11
|
services_1.DebuggerConsoleOptionService,
|
|
11
12
|
debugger_file_options_service_1.DebuggerFileOptionService,
|
|
12
13
|
debugger_telegram_options_service_1.DebuggerTelegramOptionService,
|
|
14
|
+
debugger_cloudwatch_options_service_1.DebuggerCloudwatchOptionService,
|
|
13
15
|
debugger_service_1.DebuggerService,
|
|
14
16
|
];
|
|
15
17
|
class DebuggerModule {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugger.module.js","sourceRoot":"","sources":["../../../../packages/debugger/src/debugger.module.ts"],"names":[],"mappings":";;;AACA,uEAGmC;AACnC,kEAA8D;AAC9D,yCAA0D;AAC1D,oGAA6F;AAC7F,4GAAqG;
|
|
1
|
+
{"version":3,"file":"debugger.module.js","sourceRoot":"","sources":["../../../../packages/debugger/src/debugger.module.ts"],"names":[],"mappings":";;;AACA,uEAGmC;AACnC,kEAA8D;AAC9D,yCAA0D;AAC1D,oGAA6F;AAC7F,4GAAqG;AACrG,gHAAyG;AAEzG,MAAM,SAAS,GAAG;IAChB,uCAA4B;IAC5B,yDAAyB;IACzB,iEAA6B;IAC7B,qEAA+B;IAC/B,kCAAe;CAChB,CAAC;AACF,MAAa,cAAc;IACzB,MAAM,CAAC,QAAQ,CACb,OAA8B,EAC9B,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,cAAc;YACtB,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,iDAAuB,EAAE,QAAQ,EAAE,OAAO,EAAE;gBACvD,GAAG,SAAS;aACb;YACD,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,aAAa,CAClB,OAAmC,EACnC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,iDAAuB;oBAChC,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB;gBACD,GAAG,SAAS;aACb;YACD,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,EAAE;YACf,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;CACF;AArCD,wCAqCC"}
|
|
@@ -6,6 +6,7 @@ export interface DebuggerModuleOptions {
|
|
|
6
6
|
writeIntoConsole: boolean;
|
|
7
7
|
writeIntoTelegram: boolean;
|
|
8
8
|
writeIntoFile: boolean;
|
|
9
|
+
writeIntoCloudwatch: boolean;
|
|
9
10
|
maxSize: string;
|
|
10
11
|
maxFiles: string;
|
|
11
12
|
};
|
|
@@ -13,6 +14,16 @@ export interface DebuggerModuleOptions {
|
|
|
13
14
|
chatId: string;
|
|
14
15
|
apiToken: string;
|
|
15
16
|
};
|
|
17
|
+
cloudwatch?: {
|
|
18
|
+
credential: {
|
|
19
|
+
key: string;
|
|
20
|
+
secret: string;
|
|
21
|
+
};
|
|
22
|
+
region: string;
|
|
23
|
+
logGroup: string;
|
|
24
|
+
logStream: string;
|
|
25
|
+
minLevel?: 'error' | 'warn' | 'info' | 'debug';
|
|
26
|
+
};
|
|
16
27
|
}
|
|
17
28
|
type DebuggerModuleAsyncOptions = Pick<ModuleMetadata, 'imports'> & Pick<FactoryProvider<DebuggerModuleOptions>, 'useFactory' | 'inject'>;
|
|
18
29
|
export default DebuggerModuleAsyncOptions;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Transport, { TransportStreamOptions } from 'winston-transport';
|
|
2
|
+
interface CloudwatchTransportOpts extends TransportStreamOptions {
|
|
3
|
+
region: string;
|
|
4
|
+
credentials?: {
|
|
5
|
+
accessKeyId: string;
|
|
6
|
+
secretAccessKey: string;
|
|
7
|
+
};
|
|
8
|
+
logGroupName: string;
|
|
9
|
+
logStreamName: string;
|
|
10
|
+
flushInterval?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class CloudwatchTransport extends Transport {
|
|
13
|
+
private readonly _client;
|
|
14
|
+
private readonly _logGroupName;
|
|
15
|
+
private readonly _logStreamName;
|
|
16
|
+
private readonly _flushInterval;
|
|
17
|
+
private _buffer;
|
|
18
|
+
private _timer;
|
|
19
|
+
private _flushing;
|
|
20
|
+
private _ready;
|
|
21
|
+
constructor(opts: CloudwatchTransportOpts);
|
|
22
|
+
log(info: any, cb: () => void): void;
|
|
23
|
+
private _scheduleFlush;
|
|
24
|
+
private _ensureStream;
|
|
25
|
+
private _createIgnoringExisting;
|
|
26
|
+
private _flush;
|
|
27
|
+
private _chunk;
|
|
28
|
+
close(): void;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudwatchTransport = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const winston_transport_1 = tslib_1.__importDefault(require("winston-transport"));
|
|
6
|
+
const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
|
|
7
|
+
// Limiti dell'API PutLogEvents: max 10.000 eventi e 1.048.576 byte per batch,
|
|
8
|
+
// dove ogni evento conta come byte UTF-8 del messaggio + 26 byte di overhead.
|
|
9
|
+
const MAX_BATCH_COUNT = 10000;
|
|
10
|
+
const MAX_BATCH_BYTES = 1048576;
|
|
11
|
+
const EVENT_OVERHEAD = 26;
|
|
12
|
+
const FLUSH_THRESHOLD = 1000;
|
|
13
|
+
class CloudwatchTransport extends winston_transport_1.default {
|
|
14
|
+
constructor(opts) {
|
|
15
|
+
super(opts);
|
|
16
|
+
this._buffer = [];
|
|
17
|
+
this._timer = null;
|
|
18
|
+
this._flushing = false;
|
|
19
|
+
this._ready = null;
|
|
20
|
+
this._client = new client_cloudwatch_logs_1.CloudWatchLogsClient({
|
|
21
|
+
region: opts.region,
|
|
22
|
+
...(opts.credentials ? { credentials: opts.credentials } : {}),
|
|
23
|
+
});
|
|
24
|
+
this._logGroupName = opts.logGroupName;
|
|
25
|
+
this._logStreamName = opts.logStreamName;
|
|
26
|
+
this._flushInterval = opts.flushInterval ?? 2000;
|
|
27
|
+
}
|
|
28
|
+
log(info, cb) {
|
|
29
|
+
setImmediate(() => this.emit('logged', info));
|
|
30
|
+
const message = info[Symbol.for('message')] ?? JSON.stringify(info);
|
|
31
|
+
this._buffer.push({ timestamp: Date.now(), message });
|
|
32
|
+
if (this._buffer.length >= FLUSH_THRESHOLD) {
|
|
33
|
+
void this._flush();
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this._scheduleFlush();
|
|
37
|
+
}
|
|
38
|
+
cb();
|
|
39
|
+
}
|
|
40
|
+
_scheduleFlush() {
|
|
41
|
+
if (this._timer)
|
|
42
|
+
return;
|
|
43
|
+
this._timer = setTimeout(() => {
|
|
44
|
+
this._timer = null;
|
|
45
|
+
void this._flush();
|
|
46
|
+
}, this._flushInterval);
|
|
47
|
+
}
|
|
48
|
+
async _ensureStream() {
|
|
49
|
+
if (this._ready)
|
|
50
|
+
return this._ready;
|
|
51
|
+
this._ready = (async () => {
|
|
52
|
+
await this._createIgnoringExisting(new client_cloudwatch_logs_1.CreateLogGroupCommand({ logGroupName: this._logGroupName }));
|
|
53
|
+
await this._createIgnoringExisting(new client_cloudwatch_logs_1.CreateLogStreamCommand({
|
|
54
|
+
logGroupName: this._logGroupName,
|
|
55
|
+
logStreamName: this._logStreamName,
|
|
56
|
+
}));
|
|
57
|
+
})();
|
|
58
|
+
return this._ready;
|
|
59
|
+
}
|
|
60
|
+
async _createIgnoringExisting(command) {
|
|
61
|
+
try {
|
|
62
|
+
await this._client.send(command);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
// se group/stream esistono già non è un errore; altrimenti rilancio e
|
|
66
|
+
// azzero _ready così un log successivo riprova la creazione.
|
|
67
|
+
if (err?.name !== 'ResourceAlreadyExistsException') {
|
|
68
|
+
this._ready = null;
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async _flush() {
|
|
74
|
+
if (this._flushing || this._buffer.length === 0)
|
|
75
|
+
return;
|
|
76
|
+
this._flushing = true;
|
|
77
|
+
if (this._timer) {
|
|
78
|
+
clearTimeout(this._timer);
|
|
79
|
+
this._timer = null;
|
|
80
|
+
}
|
|
81
|
+
// gli eventi di un batch devono essere ordinati per timestamp crescente.
|
|
82
|
+
const events = this._buffer
|
|
83
|
+
.splice(0)
|
|
84
|
+
.sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0));
|
|
85
|
+
try {
|
|
86
|
+
await this._ensureStream();
|
|
87
|
+
for (const batch of this._chunk(events)) {
|
|
88
|
+
await this._client.send(new client_cloudwatch_logs_1.PutLogEventsCommand({
|
|
89
|
+
logGroupName: this._logGroupName,
|
|
90
|
+
logStreamName: this._logStreamName,
|
|
91
|
+
logEvents: batch,
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
// non rimettiamo in coda gli eventi falliti per evitare crescita
|
|
97
|
+
// illimitata del buffer: il logging non deve mai far crashare l'app.
|
|
98
|
+
console.error('[CloudwatchTransport] flush failed:', err);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
this._flushing = false;
|
|
102
|
+
if (this._buffer.length > 0)
|
|
103
|
+
this._scheduleFlush();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
*_chunk(events) {
|
|
107
|
+
let batch = [];
|
|
108
|
+
let bytes = 0;
|
|
109
|
+
for (const event of events) {
|
|
110
|
+
const size = Buffer.byteLength(event.message ?? '', 'utf8') + EVENT_OVERHEAD;
|
|
111
|
+
if (batch.length >= MAX_BATCH_COUNT || bytes + size > MAX_BATCH_BYTES) {
|
|
112
|
+
if (batch.length)
|
|
113
|
+
yield batch;
|
|
114
|
+
batch = [];
|
|
115
|
+
bytes = 0;
|
|
116
|
+
}
|
|
117
|
+
batch.push(event);
|
|
118
|
+
bytes += size;
|
|
119
|
+
}
|
|
120
|
+
if (batch.length)
|
|
121
|
+
yield batch;
|
|
122
|
+
}
|
|
123
|
+
close() {
|
|
124
|
+
if (this._timer) {
|
|
125
|
+
clearTimeout(this._timer);
|
|
126
|
+
this._timer = null;
|
|
127
|
+
}
|
|
128
|
+
void this._flush();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.CloudwatchTransport = CloudwatchTransport;
|
|
132
|
+
//# sourceMappingURL=debugger.cloudwatch.transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugger.cloudwatch.transport.js","sourceRoot":"","sources":["../../../../../packages/debugger/src/interfaces/debugger.cloudwatch.transport.ts"],"names":[],"mappings":";;;;AAAA,kFAAsE;AACtE,4EAMyC;AAUzC,8EAA8E;AAC9E,8EAA8E;AAC9E,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,MAAa,mBAAoB,SAAQ,2BAAS;IAUhD,YAAY,IAA6B;QACvC,KAAK,CAAC,IAA8B,CAAC,CAAC;QANhC,YAAO,GAAoB,EAAE,CAAC;QAC9B,WAAM,GAA0B,IAAI,CAAC;QACrC,cAAS,GAAG,KAAK,CAAC;QAClB,WAAM,GAAyB,IAAI,CAAC;QAI1C,IAAI,CAAC,OAAO,GAAG,IAAI,6CAAoB,CAAC;YACtC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/D,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,YAAY,CA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ACZ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;CACF;AA9HD,kDA8HC"}
|
|
@@ -3,21 +3,25 @@ import { IDebuggerHttpLog } from '../interfaces/debugger.interface';
|
|
|
3
3
|
import { DebuggerConsoleOptionService } from './options/debugger.console.options.service';
|
|
4
4
|
import { DebuggerFileOptionService } from './options/debugger.file.options.service';
|
|
5
5
|
import { DebuggerTelegramOptionService } from './options/debugger.telegram.options.service';
|
|
6
|
+
import { DebuggerCloudwatchOptionService } from './options/debugger.cloudwatch.options.service';
|
|
6
7
|
import { DebuggerModuleOptions } from '../debugger.module.options';
|
|
7
8
|
export declare class DebuggerService implements IDebuggerService {
|
|
8
9
|
private readonly _options;
|
|
9
10
|
private readonly _consoleOptions;
|
|
10
11
|
private readonly _fileOptions;
|
|
11
12
|
private readonly _telegramOptions;
|
|
13
|
+
private readonly _cloudwatchOptions;
|
|
12
14
|
private readonly writeIntoFile;
|
|
13
15
|
private readonly writeIntoConsole;
|
|
14
16
|
private readonly writeIntoTelegram;
|
|
17
|
+
private readonly writeIntoCloudwatch;
|
|
15
18
|
private _consoleLogger;
|
|
16
19
|
private _fileLogger;
|
|
17
20
|
private _fileErrorLogger;
|
|
18
21
|
private _fileDefaultLogger;
|
|
19
22
|
private _telegramLogger;
|
|
20
|
-
|
|
23
|
+
private _cloudwatchLogger;
|
|
24
|
+
constructor(_options: DebuggerModuleOptions, _consoleOptions: DebuggerConsoleOptionService, _fileOptions: DebuggerFileOptionService, _telegramOptions: DebuggerTelegramOptionService, _cloudwatchOptions: DebuggerCloudwatchOptionService);
|
|
21
25
|
info(message: string, data: any): void;
|
|
22
26
|
debug(message: string, data: any): void;
|
|
23
27
|
warn(message: string, data: any): void;
|
|
@@ -8,19 +8,22 @@ const debugger_interface_1 = require("../interfaces/debugger.interface");
|
|
|
8
8
|
const debugger_console_options_service_1 = require("./options/debugger.console.options.service");
|
|
9
9
|
const debugger_file_options_service_1 = require("./options/debugger.file.options.service");
|
|
10
10
|
const debugger_telegram_options_service_1 = require("./options/debugger.telegram.options.service");
|
|
11
|
+
const debugger_cloudwatch_options_service_1 = require("./options/debugger.cloudwatch.options.service");
|
|
11
12
|
const debugger_module_options_1 = require("../debugger.module.options");
|
|
12
13
|
let DebuggerService = class DebuggerService {
|
|
13
|
-
constructor(_options, _consoleOptions, _fileOptions, _telegramOptions) {
|
|
14
|
+
constructor(_options, _consoleOptions, _fileOptions, _telegramOptions, _cloudwatchOptions) {
|
|
14
15
|
this._options = _options;
|
|
15
16
|
this._consoleOptions = _consoleOptions;
|
|
16
17
|
this._fileOptions = _fileOptions;
|
|
17
18
|
this._telegramOptions = _telegramOptions;
|
|
19
|
+
this._cloudwatchOptions = _cloudwatchOptions;
|
|
18
20
|
// logger = WinstonModule.createLogger({
|
|
19
21
|
// transports: [new winston.transports.File({ filename: 'combined.log' })],
|
|
20
22
|
// });
|
|
21
23
|
this.writeIntoConsole = this._options.system.writeIntoConsole;
|
|
22
24
|
this.writeIntoTelegram = this._options.system.writeIntoTelegram;
|
|
23
25
|
this.writeIntoFile = this._options.system.writeIntoFile;
|
|
26
|
+
this.writeIntoCloudwatch = this._options.system.writeIntoCloudwatch;
|
|
24
27
|
if (this.writeIntoConsole) {
|
|
25
28
|
const consoleOptions = this._consoleOptions.createLoggerOptions();
|
|
26
29
|
this._consoleLogger = (0, winston_1.createLogger)(consoleOptions);
|
|
@@ -37,6 +40,10 @@ let DebuggerService = class DebuggerService {
|
|
|
37
40
|
this._fileErrorLogger = (0, winston_1.createLogger)(fileErrorOptions);
|
|
38
41
|
this._fileDefaultLogger = (0, winston_1.createLogger)(fileDefaultOptions);
|
|
39
42
|
}
|
|
43
|
+
if (this.writeIntoCloudwatch) {
|
|
44
|
+
const cloudwatchOptions = this._cloudwatchOptions.createLoggerOptions();
|
|
45
|
+
this._cloudwatchLogger = (0, winston_1.createLogger)(cloudwatchOptions);
|
|
46
|
+
}
|
|
40
47
|
}
|
|
41
48
|
info(message, data) {
|
|
42
49
|
if (this.writeIntoConsole)
|
|
@@ -45,12 +52,16 @@ let DebuggerService = class DebuggerService {
|
|
|
45
52
|
this._fileDefaultLogger.info(message, data);
|
|
46
53
|
if (this.writeIntoTelegram)
|
|
47
54
|
this._telegramLogger.info(message, data);
|
|
55
|
+
if (this.writeIntoCloudwatch)
|
|
56
|
+
this._cloudwatchLogger.info(message, data);
|
|
48
57
|
}
|
|
49
58
|
debug(message, data) {
|
|
50
59
|
if (this.writeIntoConsole)
|
|
51
60
|
this._consoleLogger.log('debug', message, data);
|
|
52
61
|
if (this.writeIntoFile)
|
|
53
62
|
this._fileDefaultLogger.debug(message, data);
|
|
63
|
+
if (this.writeIntoCloudwatch)
|
|
64
|
+
this._cloudwatchLogger.debug(message, data);
|
|
54
65
|
}
|
|
55
66
|
warn(message, data) {
|
|
56
67
|
if (this.writeIntoConsole)
|
|
@@ -59,6 +70,8 @@ let DebuggerService = class DebuggerService {
|
|
|
59
70
|
this._fileDefaultLogger.warn(message, data);
|
|
60
71
|
if (this.writeIntoTelegram)
|
|
61
72
|
this._telegramLogger.warn(message, data);
|
|
73
|
+
if (this.writeIntoCloudwatch)
|
|
74
|
+
this._cloudwatchLogger.warn(message, data);
|
|
62
75
|
}
|
|
63
76
|
error(message, data) {
|
|
64
77
|
if (this.writeIntoConsole)
|
|
@@ -67,6 +80,8 @@ let DebuggerService = class DebuggerService {
|
|
|
67
80
|
this._fileErrorLogger.error(message, data);
|
|
68
81
|
if (this.writeIntoTelegram)
|
|
69
82
|
this._telegramLogger.error(message, data);
|
|
83
|
+
if (this.writeIntoCloudwatch)
|
|
84
|
+
this._cloudwatchLogger.error(message, data);
|
|
70
85
|
}
|
|
71
86
|
infoHttp(requestId, log, error) {
|
|
72
87
|
const body = new debugger_interface_1.DebuggerHttpBody(requestId, log, error);
|
|
@@ -76,6 +91,8 @@ let DebuggerService = class DebuggerService {
|
|
|
76
91
|
this._fileDefaultLogger.info(log.description, body);
|
|
77
92
|
if (this.writeIntoTelegram)
|
|
78
93
|
this._telegramLogger.info(log.description, body);
|
|
94
|
+
if (this.writeIntoCloudwatch)
|
|
95
|
+
this._cloudwatchLogger.info(log.description, body);
|
|
79
96
|
}
|
|
80
97
|
debugHttp(requestId, log, error) {
|
|
81
98
|
const body = new debugger_interface_1.DebuggerHttpBody(requestId, log, error);
|
|
@@ -85,6 +102,8 @@ let DebuggerService = class DebuggerService {
|
|
|
85
102
|
this._fileDefaultLogger.debug(log.description, body);
|
|
86
103
|
if (this.writeIntoTelegram)
|
|
87
104
|
this._telegramLogger.debug(log.description, body);
|
|
105
|
+
if (this.writeIntoCloudwatch)
|
|
106
|
+
this._cloudwatchLogger.debug(log.description, body);
|
|
88
107
|
}
|
|
89
108
|
warnHttp(requestId, log, error) {
|
|
90
109
|
const body = new debugger_interface_1.DebuggerHttpBody(requestId, log, error);
|
|
@@ -94,6 +113,8 @@ let DebuggerService = class DebuggerService {
|
|
|
94
113
|
this._fileDefaultLogger.warn(log.description, body);
|
|
95
114
|
if (this.writeIntoTelegram)
|
|
96
115
|
this._telegramLogger.warn(log.description, body);
|
|
116
|
+
if (this.writeIntoCloudwatch)
|
|
117
|
+
this._cloudwatchLogger.warn(log.description, body);
|
|
97
118
|
}
|
|
98
119
|
errorHttp(requestId, log, error) {
|
|
99
120
|
const body = new debugger_interface_1.DebuggerHttpBody(requestId, log, error);
|
|
@@ -103,6 +124,8 @@ let DebuggerService = class DebuggerService {
|
|
|
103
124
|
this._fileErrorLogger.error(log.description, body);
|
|
104
125
|
if (this.writeIntoTelegram)
|
|
105
126
|
this._telegramLogger.error(log.description, body);
|
|
127
|
+
if (this.writeIntoCloudwatch)
|
|
128
|
+
this._cloudwatchLogger.error(log.description, body);
|
|
106
129
|
}
|
|
107
130
|
};
|
|
108
131
|
exports.DebuggerService = DebuggerService;
|
|
@@ -111,6 +134,7 @@ exports.DebuggerService = DebuggerService = tslib_1.__decorate([
|
|
|
111
134
|
tslib_1.__param(0, (0, common_1.Inject)(debugger_module_options_1.DEBUGGER_CONFIG_OPTIONS)),
|
|
112
135
|
tslib_1.__metadata("design:paramtypes", [Object, debugger_console_options_service_1.DebuggerConsoleOptionService,
|
|
113
136
|
debugger_file_options_service_1.DebuggerFileOptionService,
|
|
114
|
-
debugger_telegram_options_service_1.DebuggerTelegramOptionService
|
|
137
|
+
debugger_telegram_options_service_1.DebuggerTelegramOptionService,
|
|
138
|
+
debugger_cloudwatch_options_service_1.DebuggerCloudwatchOptionService])
|
|
115
139
|
], DebuggerService);
|
|
116
140
|
//# sourceMappingURL=debugger.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugger.service.js","sourceRoot":"","sources":["../../../../../packages/debugger/src/services/debugger.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,qCAA+C;AAG/C,yEAG0C;AAC1C,iGAA0F;AAC1F,2FAAoF;AACpF,mGAA4F;AAC5F,wEAGoC;AAG7B,IAAM,eAAe,GAArB,MAAM,eAAe;
|
|
1
|
+
{"version":3,"file":"debugger.service.js","sourceRoot":"","sources":["../../../../../packages/debugger/src/services/debugger.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,qCAA+C;AAG/C,yEAG0C;AAC1C,iGAA0F;AAC1F,2FAAoF;AACpF,mGAA4F;AAC5F,uGAAgG;AAChG,wEAGoC;AAG7B,IAAM,eAAe,GAArB,MAAM,eAAe;IAY1B,YAImB,QAA+B,EAC/B,eAA6C,EAC7C,YAAuC,EACvC,gBAA+C,EAC/C,kBAAmD;QAJnD,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,oBAAe,GAAf,eAAe,CAA8B;QAC7C,iBAAY,GAAZ,YAAY,CAA2B;QACvC,qBAAgB,GAAhB,gBAAgB,CAA+B;Q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Ae,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,mBAAmB;YAC1B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,SAAS,CAAC,SAAiB,EAAE,GAAqB,EAAE,KAAW;QAC7D,MAAM,IAAI,GAAG,IAAI,qCAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACzD,IAAI,IAAI,CAAC,gBAAgB;YACvB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC1D,IAAI,IAAI,CAAC,aAAa;YAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC3E,IAAI,IAAI,CAAC,iBAAiB;YACxB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,IAAI,CAAC,mBAAmB;YAC1B,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAvHY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAgBR,mBAAA,IAAA,eAAM,EAAC,iDAAuB,CAAC,CAAA;qDAEE,+DAA4B;QAC/B,yDAAyB;QACrB,iEAA6B;QAC3B,qEAA+B;GApB3D,eAAe,CAuH3B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LoggerOptions } from 'winston';
|
|
2
|
+
import { IDebuggerOptionService } from '../../interfaces';
|
|
3
|
+
import { DebuggerModuleOptions } from '../../debugger.module.options';
|
|
4
|
+
export declare class DebuggerCloudwatchOptionService implements IDebuggerOptionService {
|
|
5
|
+
private readonly _options;
|
|
6
|
+
private readonly writeIntoCloudwatch;
|
|
7
|
+
constructor(_options: DebuggerModuleOptions);
|
|
8
|
+
createLoggerOptions(): LoggerOptions;
|
|
9
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebuggerCloudwatchOptionService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const winston_1 = require("winston");
|
|
7
|
+
const errors_1 = require("@tc-libs/errors");
|
|
8
|
+
const debugger_cloudwatch_transport_1 = require("../../interfaces/debugger.cloudwatch.transport");
|
|
9
|
+
const debugger_module_options_1 = require("../../debugger.module.options");
|
|
10
|
+
const { combine, timestamp, metadata, printf } = winston_1.format;
|
|
11
|
+
let DebuggerCloudwatchOptionService = class DebuggerCloudwatchOptionService {
|
|
12
|
+
constructor(_options) {
|
|
13
|
+
this._options = _options;
|
|
14
|
+
this.writeIntoCloudwatch = this._options.system.writeIntoCloudwatch;
|
|
15
|
+
}
|
|
16
|
+
createLoggerOptions() {
|
|
17
|
+
const transports = [];
|
|
18
|
+
if (this.writeIntoCloudwatch) {
|
|
19
|
+
const cw = this._options.cloudwatch;
|
|
20
|
+
if (!cw) {
|
|
21
|
+
throw new Error('DebuggerModule: writeIntoCloudwatch è abilitato ma manca la configurazione "cloudwatch".');
|
|
22
|
+
}
|
|
23
|
+
transports.push(new debugger_cloudwatch_transport_1.CloudwatchTransport({
|
|
24
|
+
region: cw.region,
|
|
25
|
+
credentials: {
|
|
26
|
+
accessKeyId: cw.credential.key,
|
|
27
|
+
secretAccessKey: cw.credential.secret,
|
|
28
|
+
},
|
|
29
|
+
logGroupName: cw.logGroup,
|
|
30
|
+
logStreamName: cw.logStream,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
const loggerOptions = {
|
|
34
|
+
// filtra per livello minimo: il logger scarta i livelli meno gravi prima
|
|
35
|
+
// ancora che raggiungano il transport (es. 'warn' => warn + error).
|
|
36
|
+
level: this._options.cloudwatch?.minLevel ?? 'info',
|
|
37
|
+
format: combine(metadata({ fillExcept: ['message', 'level', 'timestamp', 'label'] }), timestamp({ format: 'DD/MM/YY HH:mm:ss Z' }), printf(({ level, message, timestamp, metadata: meta }) => {
|
|
38
|
+
// log strutturato in JSON, interrogabile da CloudWatch Logs Insights
|
|
39
|
+
const entry = { level, message, timestamp };
|
|
40
|
+
const meta_ = meta;
|
|
41
|
+
if (meta_ && Object.keys(meta_).length) {
|
|
42
|
+
const flat = { ...meta_ };
|
|
43
|
+
const exception = flat['exception'];
|
|
44
|
+
if (exception instanceof Error) {
|
|
45
|
+
flat['exception'] = {
|
|
46
|
+
message: exception.message,
|
|
47
|
+
stack: exception.stack,
|
|
48
|
+
...(exception instanceof errors_1.ApiError
|
|
49
|
+
? { data: exception.data }
|
|
50
|
+
: {}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
Object.assign(entry, flat);
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
return JSON.stringify(entry);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return JSON.stringify({ level, message, timestamp });
|
|
60
|
+
}
|
|
61
|
+
})),
|
|
62
|
+
transports,
|
|
63
|
+
};
|
|
64
|
+
return loggerOptions;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
exports.DebuggerCloudwatchOptionService = DebuggerCloudwatchOptionService;
|
|
68
|
+
exports.DebuggerCloudwatchOptionService = DebuggerCloudwatchOptionService = tslib_1.__decorate([
|
|
69
|
+
(0, common_1.Injectable)(),
|
|
70
|
+
tslib_1.__param(0, (0, common_1.Inject)(debugger_module_options_1.DEBUGGER_CONFIG_OPTIONS)),
|
|
71
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
72
|
+
], DebuggerCloudwatchOptionService);
|
|
73
|
+
//# sourceMappingURL=debugger.cloudwatch.options.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugger.cloudwatch.options.service.js","sourceRoot":"","sources":["../../../../../../packages/debugger/src/services/options/debugger.cloudwatch.options.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,qCAAgD;AAChD,4CAA2C;AAC3C,kGAAqF;AAErF,2EAGuC;AACvC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,gBAAM,CAAC;AAGjD,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAG1C,YAEmB,QAA+B;QAA/B,aAAQ,GAAR,QAAQ,CAAuB;QAEhD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC;IACtE,CAAC;IAED,mBAAmB;QACjB,MAAM,UAAU,GAAG,EAAE,CAAC;QAEtB,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YACpC,IAAI,CAAC,EAAE,EAAE,CAAC;gBACR,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;YACJ,CAAC;YACD,UAAU,CAAC,IAAI,CACb,IAAI,mDAAmB,CAAC;gBACtB,MAAM,EAAE,EAAE,CAAC,MAAM;gBACjB,WAAW,EAAE;oBACX,WAAW,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG;oBAC9B,eAAe,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM;iBACtC;gBACD,YAAY,EAAE,EAAE,CAAC,QAAQ;gBACzB,aAAa,EAAE,EAAE,CAAC,SAAS;aAC5B,CAAC,CACH,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAAkB;YACnC,yEAAyE;YACzE,oEAAoE;YACpE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,IAAI,MAAM;YACn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