@abyss-project/monitor 1.0.2 → 1.0.4
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/dist/api/application-cron-task.admin.api.d.ts +10 -10
- package/dist/api/application-cron-task.admin.api.js +40 -40
- package/dist/api/application-cron-task.api.d.ts +10 -10
- package/dist/api/application-cron-task.api.js +40 -40
- package/dist/api/application-log.admin.api.d.ts +3 -3
- package/dist/api/application-log.admin.api.js +12 -12
- package/dist/api/application-log.api.d.ts +4 -4
- package/dist/api/application-log.api.js +16 -16
- package/dist/api/application-stats.admin.api.d.ts +3 -3
- package/dist/api/application-stats.admin.api.js +12 -12
- package/dist/api/application-stats.api.d.ts +4 -4
- package/dist/api/application-stats.api.js +16 -16
- package/dist/api/application-store.admin.api.d.ts +6 -6
- package/dist/api/application-store.admin.api.js +24 -24
- package/dist/api/application-store.api.d.ts +6 -6
- package/dist/api/application-store.api.js +24 -24
- package/dist/api/application-store.public.api.d.ts +3 -3
- package/dist/api/application-store.public.api.js +12 -12
- package/dist/api/application.admin.api.d.ts +7 -7
- package/dist/api/application.admin.api.js +28 -28
- package/dist/api/application.api.d.ts +10 -9
- package/dist/api/application.api.js +40 -36
- package/dist/api/index.d.ts +12 -12
- package/dist/api/index.js +28 -24
- package/dist/api/monitor.api.d.ts +2 -2
- package/dist/api/monitor.api.js +8 -8
- package/dist/frameworks/express/decorators.d.ts +52 -52
- package/dist/frameworks/express/decorators.js +163 -163
- package/dist/frameworks/express/index.d.ts +16 -16
- package/dist/frameworks/express/index.js +170 -166
- package/dist/frameworks/express/metadata.d.ts +9 -9
- package/dist/frameworks/express/metadata.js +12 -12
- package/dist/frameworks/index.d.ts +1 -1
- package/dist/frameworks/index.js +17 -13
- package/dist/index.d.ts +46 -46
- package/dist/index.js +105 -101
- package/dist/middlewares/context.middleware.d.ts +12 -12
- package/dist/middlewares/context.middleware.js +39 -39
- package/dist/middlewares/index.d.ts +3 -3
- package/dist/middlewares/index.js +19 -15
- package/dist/middlewares/logger-endpoint.middleware.d.ts +5 -5
- package/dist/middlewares/logger-endpoint.middleware.js +75 -75
- package/dist/middlewares/logger-setup.middleware.d.ts +5 -5
- package/dist/middlewares/logger-setup.middleware.js +16 -16
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.js +17 -13
- package/dist/models/logger.model.d.ts +55 -55
- package/dist/models/logger.model.js +201 -201
- package/dist/models/stats-publisher.model.d.ts +20 -20
- package/dist/models/stats-publisher.model.js +113 -113
- package/dist/types/enum/api-error.enum.d.ts +20 -20
- package/dist/types/enum/api-error.enum.js +25 -25
- package/dist/types/enum/api-method.enum.d.ts +7 -7
- package/dist/types/enum/api-method.enum.js +11 -11
- package/dist/types/enum/application-alert-type.enum.d.ts +5 -5
- package/dist/types/enum/application-alert-type.enum.js +9 -9
- package/dist/types/enum/application-stats-type.enum.d.ts +5 -5
- package/dist/types/enum/application-stats-type.enum.js +9 -9
- package/dist/types/enum/index.d.ts +7 -7
- package/dist/types/enum/index.js +23 -19
- package/dist/types/enum/log-level.enum.d.ts +6 -6
- package/dist/types/enum/log-level.enum.js +10 -10
- package/dist/types/enum/log-scenario.enum.d.ts +5 -5
- package/dist/types/enum/log-scenario.enum.js +9 -9
- package/dist/types/enum/webhook-type.enum.d.ts +3 -3
- package/dist/types/enum/webhook-type.enum.js +7 -7
- package/dist/types/index.d.ts +18 -18
- package/dist/types/index.js +18 -14
- package/dist/types/interface/api/index.d.ts +27 -27
- package/dist/types/interface/api/index.js +43 -39
- package/dist/types/interface/api/requests/application-cron-task.admin.request.d.ts +50 -51
- package/dist/types/interface/api/requests/application-cron-task.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application-cron-task.request.d.ts +61 -62
- package/dist/types/interface/api/requests/application-cron-task.request.js +2 -2
- package/dist/types/interface/api/requests/application-log.admin.request.d.ts +19 -20
- package/dist/types/interface/api/requests/application-log.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application-log.request.d.ts +53 -54
- package/dist/types/interface/api/requests/application-log.request.js +2 -2
- package/dist/types/interface/api/requests/application-stats.admin.request.d.ts +13 -14
- package/dist/types/interface/api/requests/application-stats.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application-stats.request.d.ts +31 -32
- package/dist/types/interface/api/requests/application-stats.request.js +2 -2
- package/dist/types/interface/api/requests/application-store.admin.request.d.ts +34 -35
- package/dist/types/interface/api/requests/application-store.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application-store.public.request.d.ts +8 -9
- package/dist/types/interface/api/requests/application-store.public.request.js +2 -2
- package/dist/types/interface/api/requests/application-store.request.d.ts +39 -40
- package/dist/types/interface/api/requests/application-store.request.js +2 -2
- package/dist/types/interface/api/requests/application.admin.request.d.ts +18 -19
- package/dist/types/interface/api/requests/application.admin.request.js +2 -2
- package/dist/types/interface/api/requests/application.request.d.ts +35 -33
- package/dist/types/interface/api/requests/application.request.js +2 -2
- package/dist/types/interface/api/responses/application-cron-task.admin.response.d.ts +30 -30
- package/dist/types/interface/api/responses/application-cron-task.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application-cron-task.response.d.ts +30 -30
- package/dist/types/interface/api/responses/application-cron-task.response.js +2 -2
- package/dist/types/interface/api/responses/application-log.admin.response.d.ts +10 -10
- package/dist/types/interface/api/responses/application-log.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application-log.response.d.ts +10 -10
- package/dist/types/interface/api/responses/application-log.response.js +2 -2
- package/dist/types/interface/api/responses/application-stats.admin.response.d.ts +6 -6
- package/dist/types/interface/api/responses/application-stats.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application-stats.response.d.ts +10 -10
- package/dist/types/interface/api/responses/application-stats.response.js +2 -2
- package/dist/types/interface/api/responses/application-store.admin.response.d.ts +17 -17
- package/dist/types/interface/api/responses/application-store.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application-store.public.response.d.ts +21 -21
- package/dist/types/interface/api/responses/application-store.public.response.js +2 -2
- package/dist/types/interface/api/responses/application-store.response.d.ts +17 -17
- package/dist/types/interface/api/responses/application-store.response.js +2 -2
- package/dist/types/interface/api/responses/application.admin.response.d.ts +33 -33
- package/dist/types/interface/api/responses/application.admin.response.js +2 -2
- package/dist/types/interface/api/responses/application.response.d.ts +129 -121
- package/dist/types/interface/api/responses/application.response.js +2 -2
- package/dist/types/interface/api/responses/monitor.response.d.ts +7 -7
- package/dist/types/interface/api/responses/monitor.response.js +2 -2
- package/dist/types/interface/api/type-message/api-error.d.ts +8 -8
- package/dist/types/interface/api/type-message/api-error.js +2 -2
- package/dist/types/interface/api/type-message/base-order.d.ts +4 -4
- package/dist/types/interface/api/type-message/base-order.js +2 -2
- package/dist/types/interface/api/type-message/base-paginate.d.ts +10 -10
- package/dist/types/interface/api/type-message/base-paginate.js +2 -2
- package/dist/types/interface/api/type-message/response.d.ts +5 -5
- package/dist/types/interface/api/type-message/response.js +2 -2
- package/dist/types/interface/index.d.ts +9 -8
- package/dist/types/interface/index.js +25 -20
- package/dist/types/interface/models/application-cron-task-history.model.d.ts +11 -11
- package/dist/types/interface/models/application-cron-task-history.model.js +2 -2
- package/dist/types/interface/models/application-cron-task.model.d.ts +14 -14
- package/dist/types/interface/models/application-cron-task.model.js +2 -2
- package/dist/types/interface/models/application-event.model.d.ts +18 -0
- package/dist/types/interface/{api/requests/abyss.admin.request.js → models/application-event.model.js} +2 -2
- package/dist/types/interface/models/application-log-endpoint.model.d.ts +20 -20
- package/dist/types/interface/models/application-log-endpoint.model.js +2 -2
- package/dist/types/interface/models/application-log.model.d.ts +23 -21
- package/dist/types/interface/models/application-log.model.js +2 -2
- package/dist/types/interface/models/application-stats.model.d.ts +14 -14
- package/dist/types/interface/models/application-stats.model.js +2 -2
- package/dist/types/interface/models/application-store-entry.model.d.ts +14 -14
- package/dist/types/interface/models/application-store-entry.model.js +2 -2
- package/dist/types/interface/models/application.model.d.ts +17 -15
- package/dist/types/interface/models/application.model.js +2 -2
- package/dist/utils/alert.utils.d.ts +35 -35
- package/dist/utils/alert.utils.js +138 -134
- package/dist/utils/discord-webhook-log-formatter.utils.d.ts +42 -42
- package/dist/utils/discord-webhook-log-formatter.utils.js +319 -319
- package/dist/utils/error.utils.d.ts +15 -15
- package/dist/utils/error.utils.js +24 -24
- package/dist/utils/import.utils.d.ts +1 -1
- package/dist/utils/import.utils.js +7 -7
- package/dist/utils/index.d.ts +5 -5
- package/dist/utils/index.js +21 -17
- package/dist/utils/json.utils.d.ts +1 -1
- package/dist/utils/json.utils.js +13 -13
- package/dist/utils/non-blocking-promise.utils.d.ts +2 -2
- package/dist/utils/non-blocking-promise.utils.js +11 -11
- package/package.json +5 -5
- package/dist/api/abyss.admin.api.d.ts +0 -2
- package/dist/api/abyss.admin.api.js +0 -8
- package/dist/api/application-store-entry.admin.api.d.ts +0 -6
- package/dist/api/application-store-entry.admin.api.js +0 -24
- package/dist/api/application-store-entry.api.d.ts +0 -6
- package/dist/api/application-store-entry.api.js +0 -24
- package/dist/api/application-store-entry.public.api.d.ts +0 -3
- package/dist/api/application-store-entry.public.api.js +0 -12
- package/dist/api/logger.admin.api.d.ts +0 -3
- package/dist/api/logger.admin.api.js +0 -14
- package/dist/api/user-application-alert.admin.api.d.ts +0 -7
- package/dist/api/user-application-alert.admin.api.js +0 -28
- package/dist/api/user-application-alert.api.d.ts +0 -7
- package/dist/api/user-application-alert.api.js +0 -28
- package/dist/api/user-application-cron-task.admin.api.d.ts +0 -9
- package/dist/api/user-application-cron-task.admin.api.js +0 -36
- package/dist/api/user-application-cron-task.api.d.ts +0 -9
- package/dist/api/user-application-cron-task.api.js +0 -36
- package/dist/api/user-application-log.admin.api.d.ts +0 -3
- package/dist/api/user-application-log.admin.api.js +0 -12
- package/dist/api/user-application-log.api.d.ts +0 -4
- package/dist/api/user-application-log.api.js +0 -16
- package/dist/api/user-application-stats.admin.api.d.ts +0 -3
- package/dist/api/user-application-stats.admin.api.js +0 -12
- package/dist/api/user-application-stats.api.d.ts +0 -4
- package/dist/api/user-application-stats.api.js +0 -16
- package/dist/api/user-application.admin.api.d.ts +0 -6
- package/dist/api/user-application.admin.api.js +0 -24
- package/dist/api/user-application.api.d.ts +0 -10
- package/dist/api/user-application.api.js +0 -40
- package/dist/api/user.admin.api.d.ts +0 -5
- package/dist/api/user.admin.api.js +0 -23
- package/dist/api/user.api.d.ts +0 -4
- package/dist/api/user.api.js +0 -17
- package/dist/consts.d.ts +0 -2
- package/dist/consts.js +0 -5
- package/dist/types/enum/log-type.enum.d.ts +0 -6
- package/dist/types/enum/log-type.enum.js +0 -10
- package/dist/types/enum/user-application-alert-type.enum.d.ts +0 -5
- package/dist/types/enum/user-application-alert-type.enum.js +0 -9
- package/dist/types/enum/user-application-stats-type.enum.d.ts +0 -5
- package/dist/types/enum/user-application-stats-type.enum.js +0 -9
- package/dist/types/interface/api/requests/abyss.admin.request.d.ts +0 -4
- package/dist/types/interface/api/requests/logger.admin.request.d.ts +0 -8
- package/dist/types/interface/api/requests/logger.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-alert.admin.request.d.ts +0 -44
- package/dist/types/interface/api/requests/user-application-alert.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-alert.request.d.ts +0 -50
- package/dist/types/interface/api/requests/user-application-alert.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-cron-task.admin.request.d.ts +0 -48
- package/dist/types/interface/api/requests/user-application-cron-task.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-cron-task.request.d.ts +0 -58
- package/dist/types/interface/api/requests/user-application-cron-task.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-log.admin.request.d.ts +0 -20
- package/dist/types/interface/api/requests/user-application-log.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-log.request.d.ts +0 -51
- package/dist/types/interface/api/requests/user-application-log.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-stats.admin.request.d.ts +0 -14
- package/dist/types/interface/api/requests/user-application-stats.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application-stats.request.d.ts +0 -29
- package/dist/types/interface/api/requests/user-application-stats.request.js +0 -2
- package/dist/types/interface/api/requests/user-application.admin.request.d.ts +0 -15
- package/dist/types/interface/api/requests/user-application.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user-application.request.d.ts +0 -35
- package/dist/types/interface/api/requests/user-application.request.js +0 -2
- package/dist/types/interface/api/requests/user.admin.request.d.ts +0 -18
- package/dist/types/interface/api/requests/user.admin.request.js +0 -2
- package/dist/types/interface/api/requests/user.request.d.ts +0 -3
- package/dist/types/interface/api/requests/user.request.js +0 -2
- package/dist/types/interface/api/responses/abyss.admin.response.d.ts +0 -6
- package/dist/types/interface/api/responses/abyss.admin.response.js +0 -2
- package/dist/types/interface/api/responses/logger.admin.response.d.ts +0 -7
- package/dist/types/interface/api/responses/logger.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-alert.admin.response.d.ts +0 -22
- package/dist/types/interface/api/responses/user-application-alert.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-alert.response.d.ts +0 -22
- package/dist/types/interface/api/responses/user-application-alert.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-cron-task.admin.response.d.ts +0 -27
- package/dist/types/interface/api/responses/user-application-cron-task.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-cron-task.response.d.ts +0 -27
- package/dist/types/interface/api/responses/user-application-cron-task.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-log.admin.response.d.ts +0 -11
- package/dist/types/interface/api/responses/user-application-log.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-log.response.d.ts +0 -11
- package/dist/types/interface/api/responses/user-application-log.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-stats.admin.response.d.ts +0 -7
- package/dist/types/interface/api/responses/user-application-stats.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application-stats.response.d.ts +0 -11
- package/dist/types/interface/api/responses/user-application-stats.response.js +0 -2
- package/dist/types/interface/api/responses/user-application.admin.response.d.ts +0 -17
- package/dist/types/interface/api/responses/user-application.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user-application.response.d.ts +0 -120
- package/dist/types/interface/api/responses/user-application.response.js +0 -2
- package/dist/types/interface/api/responses/user.admin.response.d.ts +0 -15
- package/dist/types/interface/api/responses/user.admin.response.js +0 -2
- package/dist/types/interface/api/responses/user.response.d.ts +0 -13
- package/dist/types/interface/api/responses/user.response.js +0 -2
- package/dist/types/interface/models/cron-task-history.model.d.ts +0 -12
- package/dist/types/interface/models/cron-task-history.model.js +0 -2
- package/dist/types/interface/models/cron-task.model.d.ts +0 -13
- package/dist/types/interface/models/cron-task.model.js +0 -2
- package/dist/types/interface/models/log-console.model.d.ts +0 -17
- package/dist/types/interface/models/log-console.model.js +0 -2
- package/dist/types/interface/models/log-endpoint.model.d.ts +0 -22
- package/dist/types/interface/models/log-endpoint.model.js +0 -2
- package/dist/types/interface/models/user-application-alert.model.d.ts +0 -44
- package/dist/types/interface/models/user-application-alert.model.js +0 -2
- package/dist/types/interface/models/user-application-cron-task-history.model.d.ts +0 -11
- package/dist/types/interface/models/user-application-cron-task-history.model.js +0 -2
- package/dist/types/interface/models/user-application-cron-task.model.d.ts +0 -14
- package/dist/types/interface/models/user-application-cron-task.model.js +0 -2
- package/dist/types/interface/models/user-application-log-endpoint.model.d.ts +0 -20
- package/dist/types/interface/models/user-application-log-endpoint.model.js +0 -2
- package/dist/types/interface/models/user-application-log.model.d.ts +0 -21
- package/dist/types/interface/models/user-application-log.model.js +0 -2
- package/dist/types/interface/models/user-application-stats.model.d.ts +0 -14
- package/dist/types/interface/models/user-application-stats.model.js +0 -2
- package/dist/types/interface/models/user-application.model.d.ts +0 -15
- package/dist/types/interface/models/user-application.model.js +0 -2
- package/dist/types/interface/models/user.model.d.ts +0 -8
- package/dist/types/interface/models/user.model.js +0 -2
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { APIMethod, ICreateApplicationLogBody, LogLevel } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
context?: string | null;
|
|
5
|
-
scenario?: string | null;
|
|
6
|
-
requestId?: string | null;
|
|
7
|
-
data?: Record<string, unknown> | null;
|
|
8
|
-
applicationLogEndpoint?: {
|
|
9
|
-
controller: string;
|
|
10
|
-
endpoint: string;
|
|
11
|
-
ip: string[];
|
|
12
|
-
method: APIMethod;
|
|
13
|
-
responseTime: number;
|
|
14
|
-
responseHttpCode: number;
|
|
15
|
-
requestParams?: Record<string, string> | null;
|
|
16
|
-
requestQuery?: Record<string, string | string[]> | null;
|
|
17
|
-
requestBody?: Record<string, unknown> | string | null;
|
|
18
|
-
responseBody?: Record<string, unknown> | string | null;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
shouldSaveStack?: boolean;
|
|
23
|
-
customerConsoleLogger?: (data: LogData) => void;
|
|
24
|
-
compact?: boolean;
|
|
25
|
-
};
|
|
26
|
-
export
|
|
27
|
-
level: LogLevel;
|
|
28
|
-
message: string;
|
|
29
|
-
stack?: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
shouldDisableConsoleLogging?: boolean;
|
|
33
|
-
shouldDisableConsoleResponseBodyLogging?: boolean;
|
|
34
|
-
shouldDisableRemoteLogging?: boolean;
|
|
35
|
-
customConsoleLogger?: (data: LogData) => void;
|
|
36
|
-
customPublishLog?: (payload: LogData, options?: Options) => Promise<void>;
|
|
37
|
-
processId?: string;
|
|
38
|
-
};
|
|
39
|
-
export declare class Logger {
|
|
40
|
-
private shouldDisableConsoleLogging;
|
|
41
|
-
private shouldDisableRemoteLogging;
|
|
42
|
-
private shouldDisableConsoleResponseBodyLogging;
|
|
43
|
-
private customConsoleLogger?;
|
|
44
|
-
private customPublishLog?;
|
|
45
|
-
private processId;
|
|
46
|
-
constructor(payload: PayloadConstructor);
|
|
47
|
-
log(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
48
|
-
debug(message: string, payload?: PayloadLog, options?: Omit<Options, 'shouldSaveStack'>): Promise<void>;
|
|
49
|
-
error(message: string | Error, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
50
|
-
info(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
51
|
-
warn(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
52
|
-
private publishLog;
|
|
53
|
-
private console;
|
|
54
|
-
}
|
|
55
|
-
export {};
|
|
1
|
+
import { APIMethod, ICreateApplicationLogBody, LogLevel } from '../types';
|
|
2
|
+
export type LogData = ICreateApplicationLogBody;
|
|
3
|
+
export type PayloadLog = {
|
|
4
|
+
context?: string | null;
|
|
5
|
+
scenario?: string | null;
|
|
6
|
+
requestId?: string | null;
|
|
7
|
+
data?: Record<string, unknown> | null;
|
|
8
|
+
applicationLogEndpoint?: {
|
|
9
|
+
controller: string;
|
|
10
|
+
endpoint: string;
|
|
11
|
+
ip: string[];
|
|
12
|
+
method: APIMethod;
|
|
13
|
+
responseTime: number;
|
|
14
|
+
responseHttpCode: number;
|
|
15
|
+
requestParams?: Record<string, string> | null;
|
|
16
|
+
requestQuery?: Record<string, string | string[]> | null;
|
|
17
|
+
requestBody?: Record<string, unknown> | string | null;
|
|
18
|
+
responseBody?: Record<string, unknown> | string | null;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type Options = {
|
|
22
|
+
shouldSaveStack?: boolean;
|
|
23
|
+
customerConsoleLogger?: (data: LogData) => void;
|
|
24
|
+
compact?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type PayloadSendLog = PayloadLog & {
|
|
27
|
+
level: LogLevel;
|
|
28
|
+
message: string;
|
|
29
|
+
stack?: string;
|
|
30
|
+
};
|
|
31
|
+
type PayloadConstructor = {
|
|
32
|
+
shouldDisableConsoleLogging?: boolean;
|
|
33
|
+
shouldDisableConsoleResponseBodyLogging?: boolean;
|
|
34
|
+
shouldDisableRemoteLogging?: boolean;
|
|
35
|
+
customConsoleLogger?: (data: LogData) => void;
|
|
36
|
+
customPublishLog?: (payload: LogData, options?: Options) => Promise<void>;
|
|
37
|
+
processId?: string;
|
|
38
|
+
};
|
|
39
|
+
export declare class Logger {
|
|
40
|
+
private shouldDisableConsoleLogging;
|
|
41
|
+
private shouldDisableRemoteLogging;
|
|
42
|
+
private shouldDisableConsoleResponseBodyLogging;
|
|
43
|
+
private customConsoleLogger?;
|
|
44
|
+
private customPublishLog?;
|
|
45
|
+
private processId;
|
|
46
|
+
constructor(payload: PayloadConstructor);
|
|
47
|
+
log(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
48
|
+
debug(message: string, payload?: PayloadLog, options?: Omit<Options, 'shouldSaveStack'>): Promise<void>;
|
|
49
|
+
error(message: string | Error, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
50
|
+
info(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
51
|
+
warn(message: string, payload?: PayloadLog, options?: Options): Promise<void>;
|
|
52
|
+
private publishLog;
|
|
53
|
+
private console;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -1,201 +1,201 @@
|
|
|
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.Logger = void 0;
|
|
7
|
-
const api_1 = require("../api");
|
|
8
|
-
const types_1 = require("../types");
|
|
9
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
10
|
-
const __1 = require("..");
|
|
11
|
-
const lodash_1 = require("lodash");
|
|
12
|
-
const alert_utils_1 = require("../utils/alert.utils");
|
|
13
|
-
const MAXIMUM_BODY_SIZE = 1024 * 1024 * 1024;
|
|
14
|
-
const MAXIMUM_FIELD_LENGTH = 255;
|
|
15
|
-
let chalk;
|
|
16
|
-
if (typeof window === 'undefined') {
|
|
17
|
-
chalk = require('chalk');
|
|
18
|
-
}
|
|
19
|
-
const INFO_LEVEL = {
|
|
20
|
-
ERROR: chalk === null || chalk === void 0 ? void 0 : chalk.red('ERROR'),
|
|
21
|
-
WARN: chalk === null || chalk === void 0 ? void 0 : chalk.bgYellow.black('WARN'),
|
|
22
|
-
INFO: chalk === null || chalk === void 0 ? void 0 : chalk.blueBright('INFO'),
|
|
23
|
-
DEBUG: chalk === null || chalk === void 0 ? void 0 : chalk.grey('DEBUG'),
|
|
24
|
-
LOG: chalk === null || chalk === void 0 ? void 0 : chalk.grey('LOG'),
|
|
25
|
-
};
|
|
26
|
-
class Logger {
|
|
27
|
-
constructor(payload) {
|
|
28
|
-
this.shouldDisableRemoteLogging = payload.shouldDisableRemoteLogging || false;
|
|
29
|
-
this.shouldDisableConsoleLogging = payload.shouldDisableConsoleLogging || false;
|
|
30
|
-
this.shouldDisableConsoleResponseBodyLogging =
|
|
31
|
-
payload.shouldDisableConsoleResponseBodyLogging || false;
|
|
32
|
-
this.processId = payload.processId || process.pid.toString();
|
|
33
|
-
this.customConsoleLogger = payload.customConsoleLogger;
|
|
34
|
-
this.customPublishLog = payload.customPublishLog;
|
|
35
|
-
}
|
|
36
|
-
async log(message, payload = {}, options) {
|
|
37
|
-
this.publishLog({ ...payload, message, level: types_1.LogLevel.LOG }, options);
|
|
38
|
-
}
|
|
39
|
-
async debug(message, payload = {}, options) {
|
|
40
|
-
this.publishLog({ ...payload, message, stack: new Error().stack, level: types_1.LogLevel.LOG }, options);
|
|
41
|
-
}
|
|
42
|
-
async error(message, payload = {}, options) {
|
|
43
|
-
if (message instanceof Error) {
|
|
44
|
-
this.publishLog({
|
|
45
|
-
...payload,
|
|
46
|
-
message: `${message.name} ${message.message}`,
|
|
47
|
-
stack: message.stack,
|
|
48
|
-
level: types_1.LogLevel.ERROR,
|
|
49
|
-
data: {
|
|
50
|
-
...payload.data,
|
|
51
|
-
errorName: message.name,
|
|
52
|
-
},
|
|
53
|
-
}, options);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.publishLog({ ...payload, message, level: types_1.LogLevel.ERROR }, options);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async info(message, payload = {}, options) {
|
|
60
|
-
this.publishLog({ ...payload, message, level: types_1.LogLevel.INFO }, options);
|
|
61
|
-
}
|
|
62
|
-
async warn(message, payload = {}, options) {
|
|
63
|
-
this.publishLog({ ...payload, message, level: types_1.LogLevel.WARN }, options);
|
|
64
|
-
}
|
|
65
|
-
async publishLog(payload, options) {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
const log = {
|
|
68
|
-
...payload,
|
|
69
|
-
dateValue: new Date(),
|
|
70
|
-
processId: this.processId,
|
|
71
|
-
};
|
|
72
|
-
try {
|
|
73
|
-
this.console(log, options === null || options === void 0 ? void 0 : options.customerConsoleLogger);
|
|
74
|
-
if (this.customPublishLog) {
|
|
75
|
-
await this.customPublishLog(log, options);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
const { applicationId, secretPublishToken } = __1.AbyssMonitorCore.getConfig();
|
|
79
|
-
if (!this.shouldDisableRemoteLogging && applicationId && secretPublishToken) {
|
|
80
|
-
const size = Buffer.byteLength(JSON.stringify(log));
|
|
81
|
-
const body = log;
|
|
82
|
-
let isBodyTruncated = false;
|
|
83
|
-
if (size >= MAXIMUM_BODY_SIZE) {
|
|
84
|
-
isBodyTruncated = true;
|
|
85
|
-
if ((_a = body.applicationLogEndpoint) === null || _a === void 0 ? void 0 : _a.requestBody) {
|
|
86
|
-
body.applicationLogEndpoint.requestBody = 'Payload Too Large';
|
|
87
|
-
}
|
|
88
|
-
if ((_b = body.applicationLogEndpoint) === null || _b === void 0 ? void 0 : _b.responseBody) {
|
|
89
|
-
body.applicationLogEndpoint.responseBody = 'Payload Too Large';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const newSize = Buffer.byteLength(JSON.stringify(body));
|
|
93
|
-
if (newSize >= MAXIMUM_BODY_SIZE) {
|
|
94
|
-
this.warn(`Unable to save log because payload is too big (more than 1Mo even after removing responseBody and requestBody)`, {
|
|
95
|
-
requestId: body.requestId
|
|
96
|
-
? (0, lodash_1.truncate)(body.requestId, { length: MAXIMUM_FIELD_LENGTH })
|
|
97
|
-
: undefined,
|
|
98
|
-
context: body.context
|
|
99
|
-
? (0, lodash_1.truncate)(body.context, { length: MAXIMUM_FIELD_LENGTH })
|
|
100
|
-
: undefined,
|
|
101
|
-
scenario: body.scenario
|
|
102
|
-
? (0, lodash_1.truncate)(body.scenario, { length: MAXIMUM_FIELD_LENGTH })
|
|
103
|
-
: undefined,
|
|
104
|
-
});
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const applicationLog = await (0, api_1.createApplicationLog)({ applicationId }, { token: secretPublishToken }, body);
|
|
108
|
-
(0, __1.nonBlockingPromise)((async () => {
|
|
109
|
-
(0, alert_utils_1.sendLogAlert)({
|
|
110
|
-
...payload,
|
|
111
|
-
logData: log,
|
|
112
|
-
logger: this,
|
|
113
|
-
applicationLogId: applicationLog.data.applicationLog.id || '',
|
|
114
|
-
compact: options === null || options === void 0 ? void 0 : options.compact,
|
|
115
|
-
});
|
|
116
|
-
})(), this);
|
|
117
|
-
if (isBodyTruncated) {
|
|
118
|
-
this.warn(`Endpoint log ${applicationLog.data.applicationLog.id} has been truncated (requestBody & responseBody) because payload was too big (more than 1Mo)`, {
|
|
119
|
-
requestId: body.requestId
|
|
120
|
-
? (0, lodash_1.truncate)(body.requestId, { length: MAXIMUM_FIELD_LENGTH })
|
|
121
|
-
: undefined,
|
|
122
|
-
context: body.context
|
|
123
|
-
? (0, lodash_1.truncate)(body.context, { length: MAXIMUM_FIELD_LENGTH })
|
|
124
|
-
: undefined,
|
|
125
|
-
scenario: body.scenario
|
|
126
|
-
? (0, lodash_1.truncate)(body.scenario, { length: MAXIMUM_FIELD_LENGTH })
|
|
127
|
-
: undefined,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
console.error(`Unable to publish log. Error: ${error}`);
|
|
135
|
-
(0, alert_utils_1.sendLogAlert)({
|
|
136
|
-
...payload,
|
|
137
|
-
logData: log,
|
|
138
|
-
logger: this,
|
|
139
|
-
author: 'AbyssMonitor Logger',
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
console(data, customConsoleLogger) {
|
|
144
|
-
if (this.shouldDisableConsoleLogging) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (customConsoleLogger) {
|
|
148
|
-
customConsoleLogger(data);
|
|
149
|
-
}
|
|
150
|
-
else if (this.customConsoleLogger) {
|
|
151
|
-
this.customConsoleLogger(data);
|
|
152
|
-
}
|
|
153
|
-
else if (data.applicationLogEndpoint) {
|
|
154
|
-
let message = `${chalk.grey((0, dayjs_1.default)().format('DD/MM/YYYY HH:mm:ss'))} | ${chalk.bgBlueBright(' API ')} | `;
|
|
155
|
-
message += `${chalk.grey(data.requestId)} | ${chalk.greenBright(types_1.APIMethod[data.applicationLogEndpoint.method])} | ${data.applicationLogEndpoint.controller} ${data.applicationLogEndpoint.endpoint} | `;
|
|
156
|
-
if (data.applicationLogEndpoint.responseHttpCode >= 100 &&
|
|
157
|
-
data.applicationLogEndpoint.responseHttpCode <= 199) {
|
|
158
|
-
message += `${chalk.blue(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
159
|
-
}
|
|
160
|
-
else if (data.applicationLogEndpoint.responseHttpCode >= 200 &&
|
|
161
|
-
data.applicationLogEndpoint.responseHttpCode <= 299) {
|
|
162
|
-
message += `${chalk.green(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
163
|
-
}
|
|
164
|
-
else if (data.applicationLogEndpoint.responseHttpCode >= 300 &&
|
|
165
|
-
data.applicationLogEndpoint.responseHttpCode <= 399) {
|
|
166
|
-
message += `${chalk.magenta(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
167
|
-
}
|
|
168
|
-
else if (data.applicationLogEndpoint.responseHttpCode >= 400 &&
|
|
169
|
-
data.applicationLogEndpoint.responseHttpCode <= 499) {
|
|
170
|
-
message += `${chalk.yellow(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
171
|
-
}
|
|
172
|
-
else if (data.applicationLogEndpoint.responseHttpCode >= 500 &&
|
|
173
|
-
data.applicationLogEndpoint.responseHttpCode <= 599) {
|
|
174
|
-
message += `${chalk.red(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
message += `${chalk.bgCyanBright.black(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
178
|
-
}
|
|
179
|
-
if (data.applicationLogEndpoint.responseTime < 50) {
|
|
180
|
-
message += ` | ${chalk.greenBright(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
181
|
-
}
|
|
182
|
-
else if (data.applicationLogEndpoint.responseTime < 150) {
|
|
183
|
-
message += ` | ${chalk.yellow(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
message += ` | ${chalk.red(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
187
|
-
}
|
|
188
|
-
message += `${(data.applicationLogEndpoint.ip || []).join(' ')} | `;
|
|
189
|
-
if (!this.shouldDisableConsoleResponseBodyLogging &&
|
|
190
|
-
(data.applicationLogEndpoint.responseHttpCode < 200 ||
|
|
191
|
-
data.applicationLogEndpoint.responseHttpCode > 399)) {
|
|
192
|
-
message += `${JSON.stringify(data.applicationLogEndpoint.responseBody)}`;
|
|
193
|
-
}
|
|
194
|
-
console.log(message);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
console.log(`${chalk.grey((0, dayjs_1.default)().format('DD/MM/YYYY HH:mm:ss'))} | ${INFO_LEVEL[types_1.LogLevel[data.level]]} | ${data.processId}${data.requestId ? ` | ${data.requestId}` : ''}${data.context ? ` | ${data.context}` : ''} | ${data.message || data.stack} `);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
exports.Logger = Logger;
|
|
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.Logger = void 0;
|
|
7
|
+
const api_1 = require("../api");
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
10
|
+
const __1 = require("..");
|
|
11
|
+
const lodash_1 = require("lodash");
|
|
12
|
+
const alert_utils_1 = require("../utils/alert.utils");
|
|
13
|
+
const MAXIMUM_BODY_SIZE = 1024 * 1024 * 1024;
|
|
14
|
+
const MAXIMUM_FIELD_LENGTH = 255;
|
|
15
|
+
let chalk;
|
|
16
|
+
if (typeof window === 'undefined') {
|
|
17
|
+
chalk = require('chalk');
|
|
18
|
+
}
|
|
19
|
+
const INFO_LEVEL = {
|
|
20
|
+
ERROR: chalk === null || chalk === void 0 ? void 0 : chalk.red('ERROR'),
|
|
21
|
+
WARN: chalk === null || chalk === void 0 ? void 0 : chalk.bgYellow.black('WARN'),
|
|
22
|
+
INFO: chalk === null || chalk === void 0 ? void 0 : chalk.blueBright('INFO'),
|
|
23
|
+
DEBUG: chalk === null || chalk === void 0 ? void 0 : chalk.grey('DEBUG'),
|
|
24
|
+
LOG: chalk === null || chalk === void 0 ? void 0 : chalk.grey('LOG'),
|
|
25
|
+
};
|
|
26
|
+
class Logger {
|
|
27
|
+
constructor(payload) {
|
|
28
|
+
this.shouldDisableRemoteLogging = payload.shouldDisableRemoteLogging || false;
|
|
29
|
+
this.shouldDisableConsoleLogging = payload.shouldDisableConsoleLogging || false;
|
|
30
|
+
this.shouldDisableConsoleResponseBodyLogging =
|
|
31
|
+
payload.shouldDisableConsoleResponseBodyLogging || false;
|
|
32
|
+
this.processId = payload.processId || process.pid.toString();
|
|
33
|
+
this.customConsoleLogger = payload.customConsoleLogger;
|
|
34
|
+
this.customPublishLog = payload.customPublishLog;
|
|
35
|
+
}
|
|
36
|
+
async log(message, payload = {}, options) {
|
|
37
|
+
this.publishLog({ ...payload, message, level: types_1.LogLevel.LOG }, options);
|
|
38
|
+
}
|
|
39
|
+
async debug(message, payload = {}, options) {
|
|
40
|
+
this.publishLog({ ...payload, message, stack: new Error().stack, level: types_1.LogLevel.LOG }, options);
|
|
41
|
+
}
|
|
42
|
+
async error(message, payload = {}, options) {
|
|
43
|
+
if (message instanceof Error) {
|
|
44
|
+
this.publishLog({
|
|
45
|
+
...payload,
|
|
46
|
+
message: `${message.name} ${message.message}`,
|
|
47
|
+
stack: message.stack,
|
|
48
|
+
level: types_1.LogLevel.ERROR,
|
|
49
|
+
data: {
|
|
50
|
+
...payload.data,
|
|
51
|
+
errorName: message.name,
|
|
52
|
+
},
|
|
53
|
+
}, options);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.publishLog({ ...payload, message, level: types_1.LogLevel.ERROR }, options);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async info(message, payload = {}, options) {
|
|
60
|
+
this.publishLog({ ...payload, message, level: types_1.LogLevel.INFO }, options);
|
|
61
|
+
}
|
|
62
|
+
async warn(message, payload = {}, options) {
|
|
63
|
+
this.publishLog({ ...payload, message, level: types_1.LogLevel.WARN }, options);
|
|
64
|
+
}
|
|
65
|
+
async publishLog(payload, options) {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const log = {
|
|
68
|
+
...payload,
|
|
69
|
+
dateValue: new Date(),
|
|
70
|
+
processId: this.processId,
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
this.console(log, options === null || options === void 0 ? void 0 : options.customerConsoleLogger);
|
|
74
|
+
if (this.customPublishLog) {
|
|
75
|
+
await this.customPublishLog(log, options);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const { applicationId, secretPublishToken } = __1.AbyssMonitorCore.getConfig();
|
|
79
|
+
if (!this.shouldDisableRemoteLogging && applicationId && secretPublishToken) {
|
|
80
|
+
const size = Buffer.byteLength(JSON.stringify(log));
|
|
81
|
+
const body = log;
|
|
82
|
+
let isBodyTruncated = false;
|
|
83
|
+
if (size >= MAXIMUM_BODY_SIZE) {
|
|
84
|
+
isBodyTruncated = true;
|
|
85
|
+
if ((_a = body.applicationLogEndpoint) === null || _a === void 0 ? void 0 : _a.requestBody) {
|
|
86
|
+
body.applicationLogEndpoint.requestBody = 'Payload Too Large';
|
|
87
|
+
}
|
|
88
|
+
if ((_b = body.applicationLogEndpoint) === null || _b === void 0 ? void 0 : _b.responseBody) {
|
|
89
|
+
body.applicationLogEndpoint.responseBody = 'Payload Too Large';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const newSize = Buffer.byteLength(JSON.stringify(body));
|
|
93
|
+
if (newSize >= MAXIMUM_BODY_SIZE) {
|
|
94
|
+
this.warn(`Unable to save log because payload is too big (more than 1Mo even after removing responseBody and requestBody)`, {
|
|
95
|
+
requestId: body.requestId
|
|
96
|
+
? (0, lodash_1.truncate)(body.requestId, { length: MAXIMUM_FIELD_LENGTH })
|
|
97
|
+
: undefined,
|
|
98
|
+
context: body.context
|
|
99
|
+
? (0, lodash_1.truncate)(body.context, { length: MAXIMUM_FIELD_LENGTH })
|
|
100
|
+
: undefined,
|
|
101
|
+
scenario: body.scenario
|
|
102
|
+
? (0, lodash_1.truncate)(body.scenario, { length: MAXIMUM_FIELD_LENGTH })
|
|
103
|
+
: undefined,
|
|
104
|
+
});
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const applicationLog = await (0, api_1.createApplicationLog)({ applicationId }, { token: secretPublishToken }, body);
|
|
108
|
+
(0, __1.nonBlockingPromise)((async () => {
|
|
109
|
+
(0, alert_utils_1.sendLogAlert)({
|
|
110
|
+
...payload,
|
|
111
|
+
logData: log,
|
|
112
|
+
logger: this,
|
|
113
|
+
applicationLogId: applicationLog.data.applicationLog.id || '',
|
|
114
|
+
compact: options === null || options === void 0 ? void 0 : options.compact,
|
|
115
|
+
});
|
|
116
|
+
})(), this);
|
|
117
|
+
if (isBodyTruncated) {
|
|
118
|
+
this.warn(`Endpoint log ${applicationLog.data.applicationLog.id} has been truncated (requestBody & responseBody) because payload was too big (more than 1Mo)`, {
|
|
119
|
+
requestId: body.requestId
|
|
120
|
+
? (0, lodash_1.truncate)(body.requestId, { length: MAXIMUM_FIELD_LENGTH })
|
|
121
|
+
: undefined,
|
|
122
|
+
context: body.context
|
|
123
|
+
? (0, lodash_1.truncate)(body.context, { length: MAXIMUM_FIELD_LENGTH })
|
|
124
|
+
: undefined,
|
|
125
|
+
scenario: body.scenario
|
|
126
|
+
? (0, lodash_1.truncate)(body.scenario, { length: MAXIMUM_FIELD_LENGTH })
|
|
127
|
+
: undefined,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
console.error(`Unable to publish log. Error: ${error}`);
|
|
135
|
+
(0, alert_utils_1.sendLogAlert)({
|
|
136
|
+
...payload,
|
|
137
|
+
logData: log,
|
|
138
|
+
logger: this,
|
|
139
|
+
author: 'AbyssMonitor Logger',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
console(data, customConsoleLogger) {
|
|
144
|
+
if (this.shouldDisableConsoleLogging) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (customConsoleLogger) {
|
|
148
|
+
customConsoleLogger(data);
|
|
149
|
+
}
|
|
150
|
+
else if (this.customConsoleLogger) {
|
|
151
|
+
this.customConsoleLogger(data);
|
|
152
|
+
}
|
|
153
|
+
else if (data.applicationLogEndpoint) {
|
|
154
|
+
let message = `${chalk.grey((0, dayjs_1.default)().format('DD/MM/YYYY HH:mm:ss'))} | ${chalk.bgBlueBright(' API ')} | `;
|
|
155
|
+
message += `${chalk.grey(data.requestId)} | ${chalk.greenBright(types_1.APIMethod[data.applicationLogEndpoint.method])} | ${data.applicationLogEndpoint.controller} ${data.applicationLogEndpoint.endpoint} | `;
|
|
156
|
+
if (data.applicationLogEndpoint.responseHttpCode >= 100 &&
|
|
157
|
+
data.applicationLogEndpoint.responseHttpCode <= 199) {
|
|
158
|
+
message += `${chalk.blue(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
159
|
+
}
|
|
160
|
+
else if (data.applicationLogEndpoint.responseHttpCode >= 200 &&
|
|
161
|
+
data.applicationLogEndpoint.responseHttpCode <= 299) {
|
|
162
|
+
message += `${chalk.green(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
163
|
+
}
|
|
164
|
+
else if (data.applicationLogEndpoint.responseHttpCode >= 300 &&
|
|
165
|
+
data.applicationLogEndpoint.responseHttpCode <= 399) {
|
|
166
|
+
message += `${chalk.magenta(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
167
|
+
}
|
|
168
|
+
else if (data.applicationLogEndpoint.responseHttpCode >= 400 &&
|
|
169
|
+
data.applicationLogEndpoint.responseHttpCode <= 499) {
|
|
170
|
+
message += `${chalk.yellow(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
171
|
+
}
|
|
172
|
+
else if (data.applicationLogEndpoint.responseHttpCode >= 500 &&
|
|
173
|
+
data.applicationLogEndpoint.responseHttpCode <= 599) {
|
|
174
|
+
message += `${chalk.red(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
message += `${chalk.bgCyanBright.black(data.applicationLogEndpoint.responseHttpCode)}`;
|
|
178
|
+
}
|
|
179
|
+
if (data.applicationLogEndpoint.responseTime < 50) {
|
|
180
|
+
message += ` | ${chalk.greenBright(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
181
|
+
}
|
|
182
|
+
else if (data.applicationLogEndpoint.responseTime < 150) {
|
|
183
|
+
message += ` | ${chalk.yellow(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
message += ` | ${chalk.red(data.applicationLogEndpoint.responseTime, 'ms')} | `;
|
|
187
|
+
}
|
|
188
|
+
message += `${(data.applicationLogEndpoint.ip || []).join(' ')} | `;
|
|
189
|
+
if (!this.shouldDisableConsoleResponseBodyLogging &&
|
|
190
|
+
(data.applicationLogEndpoint.responseHttpCode < 200 ||
|
|
191
|
+
data.applicationLogEndpoint.responseHttpCode > 399)) {
|
|
192
|
+
message += `${JSON.stringify(data.applicationLogEndpoint.responseBody)}`;
|
|
193
|
+
}
|
|
194
|
+
console.log(message);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
console.log(`${chalk.grey((0, dayjs_1.default)().format('DD/MM/YYYY HH:mm:ss'))} | ${INFO_LEVEL[types_1.LogLevel[data.level]]} | ${data.processId}${data.requestId ? ` | ${data.requestId}` : ''}${data.context ? ` | ${data.context}` : ''} | ${data.message || data.stack} `);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.Logger = Logger;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Logger, ApplicationStatsType } from '..';
|
|
3
|
-
|
|
4
|
-
interval?: number;
|
|
5
|
-
customCallback?: (values: {
|
|
6
|
-
type: ApplicationStatsType;
|
|
7
|
-
dateValue: Date;
|
|
8
|
-
processId: string;
|
|
9
|
-
value: number;
|
|
10
|
-
percentValue: number;
|
|
11
|
-
}[]) => Promise<void>;
|
|
12
|
-
logger?: Logger;
|
|
13
|
-
processId?: string;
|
|
14
|
-
};
|
|
15
|
-
export declare class StatsPublisher {
|
|
16
|
-
static interval: NodeJS.
|
|
17
|
-
static start(options?: StartOptions): void;
|
|
18
|
-
static stop(): void;
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Logger, ApplicationStatsType } from '..';
|
|
3
|
+
type StartOptions = {
|
|
4
|
+
interval?: number;
|
|
5
|
+
customCallback?: (values: {
|
|
6
|
+
type: ApplicationStatsType;
|
|
7
|
+
dateValue: Date;
|
|
8
|
+
processId: string;
|
|
9
|
+
value: number;
|
|
10
|
+
percentValue: number;
|
|
11
|
+
}[]) => Promise<void>;
|
|
12
|
+
logger?: Logger;
|
|
13
|
+
processId?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare class StatsPublisher {
|
|
16
|
+
static interval: NodeJS.Timeout | null;
|
|
17
|
+
static start(options?: StartOptions): void;
|
|
18
|
+
static stop(): void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|