@seidor-cloud-produtos/orbit-backend-lib 2.0.44 → 2.0.46

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.
@@ -32,11 +32,28 @@ class LoggerGateway {
32
32
  return acceptValues;
33
33
  }
34
34
  async log(data, props, options) {
35
- const buildedProps = this.buildProps();
36
- const cachedValue = await this.cache.get(`${LoggerGateway.cacheKey}:${props?.type}|*-${props?.actor}|*`);
35
+ const buildedProps = this.buildProps(props);
36
+ const genericKeys = (await this.cache.getKeys(`${LoggerGateway.cacheKey}:*:*`)) || [];
37
+ let choosenKey = undefined;
38
+ for (const key of genericKeys) {
39
+ const [_, type, actor] = key.split(':');
40
+ const isExactlyMatch = buildedProps.type === type && buildedProps.actor === actor;
41
+ if (isExactlyMatch) {
42
+ choosenKey = key;
43
+ break;
44
+ }
45
+ const isTypeMatch = ['*', buildedProps.type].includes(type);
46
+ const isActorMatch = ['*', buildedProps.actor].includes(actor);
47
+ if (isTypeMatch && isActorMatch) {
48
+ choosenKey = key;
49
+ }
50
+ }
51
+ const cachedValue = choosenKey
52
+ ? await this.cache.get(choosenKey)
53
+ : types_1.LOG_LEVEL.error;
37
54
  const acceptValues = LoggerGateway.buildAcceptLogLevelValues(cachedValue);
38
- if (props?.category === CategoryEnum.BUSINESS ||
39
- acceptValues.includes(buildedProps.level || types_1.LOG_LEVEL.info)) {
55
+ if (buildedProps?.category === CategoryEnum.BUSINESS ||
56
+ acceptValues.includes(buildedProps.level)) {
40
57
  return await this.register(data, buildedProps, options);
41
58
  }
42
59
  }
@@ -58,7 +75,7 @@ class LoggerGateway {
58
75
  }
59
76
  async setLevel(level, filter, ttl) {
60
77
  const fourDaysInSeconds = 345600;
61
- return await this.cache.set(`${LoggerGateway.cacheKey}:${filter.logType}-${filter.logActor}`, level, ttl || fourDaysInSeconds);
78
+ return await this.cache.set(`${LoggerGateway.cacheKey}:${filter.logType}:${filter.logActor}`, level, ttl || fourDaysInSeconds);
62
79
  }
63
80
  }
64
81
  exports.default = LoggerGateway;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seidor-cloud-produtos/orbit-backend-lib",
3
- "version": "2.0.44",
3
+ "version": "2.0.46",
4
4
  "description": "Internal lib for backend components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",