jr-common-micro 1.1.28 → 1.1.30

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.
@@ -49,7 +49,7 @@ export declare function fetchScrappingData<T>(fetchFn: (params: any) => Promise<
49
49
  data: string;
50
50
  }>): Promise<T>;
51
51
  export declare function getGrpcClient(packageName: string, grpcHost: string, grpcPort: string): import("@nestjs/microservices").ClientGrpcProxy;
52
- export declare function getStatus(codeSuccess: number, codeError: number, logger: any, data: any, text: string, logOnSuccess?: boolean): {
52
+ export declare function getStatus(codeSuccess: number, codeError: number, logger: any, data: any, text: string, logOnSuccess?: boolean, elasticsearchService?: any, elasticsearch_logs_index?: string, methodName?: string): {
53
53
  code: number;
54
54
  };
55
55
  export declare const getPrismaLogMessage: (functionName: string, options?: {
@@ -349,15 +349,33 @@ function getGrpcClient(packageName, grpcHost, grpcPort) {
349
349
  },
350
350
  });
351
351
  }
352
- function getStatus(codeSuccess, codeError, logger, data, text, logOnSuccess = false) {
352
+ function getStatus(codeSuccess, codeError, logger, data, text, logOnSuccess = false, elasticsearchService, elasticsearch_logs_index, methodName) {
353
353
  if (isEmptyAtAll(data)) {
354
354
  logger.error(`getStatus function Error: ${text} `);
355
+ if (elasticsearchService && elasticsearch_logs_index) {
356
+ elasticsearchService.log(elasticsearch_logs_index, {
357
+ action: 'getStatus',
358
+ method: methodName,
359
+ status: 'error',
360
+ message: JSON.stringify({ text, data }),
361
+ timestamp: new Date(),
362
+ });
363
+ }
355
364
  return {
356
365
  code: codeError,
357
366
  };
358
367
  }
359
368
  if (logOnSuccess) {
360
369
  logger.log(`getStatus function Success: ${text} `);
370
+ if (elasticsearchService && elasticsearch_logs_index) {
371
+ elasticsearchService.log(elasticsearch_logs_index, {
372
+ action: 'getStatus',
373
+ method: methodName,
374
+ status: 'success',
375
+ message: JSON.stringify({ text, data }),
376
+ timestamp: new Date(),
377
+ });
378
+ }
361
379
  }
362
380
  return {
363
381
  code: codeSuccess,
@@ -405,16 +423,16 @@ async function executeWithReturn(logger, logMessage, func, elasticsearchService,
405
423
  }
406
424
  catch (error) {
407
425
  logMessage.misc = { ...logMessage.misc, error };
426
+ logger.error(logMessage);
408
427
  if (elasticsearchService && elasticsearch_logs_index) {
409
428
  elasticsearchService.log(elasticsearch_logs_index, {
410
429
  action: 'executeWithReturn',
411
430
  method: methodName,
412
431
  status: 'error',
413
- message: logMessage,
432
+ message: JSON.stringify(logMessage),
414
433
  timestamp: new Date(),
415
434
  });
416
435
  }
417
- logger.error(logMessage);
418
436
  return null;
419
437
  }
420
438
  }
@@ -425,16 +443,16 @@ async function executeWithoutReturn(logger, logMessage, func, elasticsearchServi
425
443
  }
426
444
  catch (error) {
427
445
  logMessage.misc = { ...logMessage.misc, error };
446
+ logger.error(logMessage);
428
447
  if (elasticsearchService && elasticsearch_logs_index) {
429
448
  elasticsearchService.log(elasticsearch_logs_index, {
430
449
  action: 'executeWithoutReturn',
431
450
  method: methodName,
432
451
  status: 'error',
433
- message: logMessage,
452
+ message: JSON.stringify(logMessage),
434
453
  timestamp: new Date(),
435
454
  });
436
455
  }
437
- logger.error(logMessage);
438
456
  return null;
439
457
  }
440
458
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jr-common-micro",
3
- "version": "1.1.28",
3
+ "version": "1.1.30",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,