jr-common-micro 1.1.27 → 1.1.28

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.
@@ -65,6 +65,6 @@ export declare const getRedisLogMessage: (functionName: string, redis: {
65
65
  data?: any;
66
66
  misc?: Record<string, any>;
67
67
  }) => LogMessage;
68
- export declare function executeWithReturn<T extends (...args: any[]) => any>(logger: any, logMessage: LogMessage, func: T, ...args: Parameters<T>): Promise<ReturnType<T>>;
69
- export declare function executeWithoutReturn<T extends (...args: any[]) => any>(logger: any, logMessage: LogMessage, func: T, ...args: Parameters<T>): Promise<ReturnType<T>>;
68
+ export declare function executeWithReturn<T extends (...args: any[]) => any>(logger: any, logMessage: LogMessage, func: T, elasticsearchService?: any, elasticsearch_logs_index?: string, methodName?: string, ...args: Parameters<T>): Promise<ReturnType<T>>;
69
+ export declare function executeWithoutReturn<T extends (...args: any[]) => any>(logger: any, logMessage: LogMessage, func: T, elasticsearchService?: any, elasticsearch_logs_index?: string, methodName?: string, ...args: Parameters<T>): Promise<ReturnType<T>>;
70
70
  export declare function jsonStringify(val: any): string;
@@ -390,7 +390,7 @@ const getRedisLogMessage = (functionName, redis, options) => {
390
390
  };
391
391
  };
392
392
  exports.getRedisLogMessage = getRedisLogMessage;
393
- async function executeWithReturn(logger, logMessage, func, ...args) {
393
+ async function executeWithReturn(logger, logMessage, func, elasticsearchService, elasticsearch_logs_index, methodName, ...args) {
394
394
  try {
395
395
  const result = await func(...args);
396
396
  if (isEmptyAtAll(result)) {
@@ -405,17 +405,35 @@ async function executeWithReturn(logger, logMessage, func, ...args) {
405
405
  }
406
406
  catch (error) {
407
407
  logMessage.misc = { ...logMessage.misc, error };
408
+ if (elasticsearchService && elasticsearch_logs_index) {
409
+ elasticsearchService.log(elasticsearch_logs_index, {
410
+ action: 'executeWithReturn',
411
+ method: methodName,
412
+ status: 'error',
413
+ message: logMessage,
414
+ timestamp: new Date(),
415
+ });
416
+ }
408
417
  logger.error(logMessage);
409
418
  return null;
410
419
  }
411
420
  }
412
- async function executeWithoutReturn(logger, logMessage, func, ...args) {
421
+ async function executeWithoutReturn(logger, logMessage, func, elasticsearchService, elasticsearch_logs_index, methodName, ...args) {
413
422
  try {
414
423
  const result = await func(...args);
415
424
  return result;
416
425
  }
417
426
  catch (error) {
418
427
  logMessage.misc = { ...logMessage.misc, error };
428
+ if (elasticsearchService && elasticsearch_logs_index) {
429
+ elasticsearchService.log(elasticsearch_logs_index, {
430
+ action: 'executeWithoutReturn',
431
+ method: methodName,
432
+ status: 'error',
433
+ message: logMessage,
434
+ timestamp: new Date(),
435
+ });
436
+ }
419
437
  logger.error(logMessage);
420
438
  return null;
421
439
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jr-common-micro",
3
- "version": "1.1.27",
3
+ "version": "1.1.28",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,