@rockster/logger 0.0.2 → 0.1.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.
Files changed (55) hide show
  1. package/config/remote-persist.config.d.ts +14 -0
  2. package/config/remote-persist.config.js +55 -0
  3. package/config/remote-persist.config.js.map +1 -0
  4. package/env.js +16 -6
  5. package/env.js.map +1 -1
  6. package/functions/dispatch-log.d.ts +2 -0
  7. package/functions/dispatch-log.js +17 -0
  8. package/functions/dispatch-log.js.map +1 -0
  9. package/functions/enable-console.js +0 -4
  10. package/functions/enable-console.js.map +1 -1
  11. package/functions/get-error-infos.d.ts +2 -2
  12. package/functions/get-error-infos.js +40 -13
  13. package/functions/get-error-infos.js.map +1 -1
  14. package/functions/index.d.ts +3 -0
  15. package/functions/index.js +3 -0
  16. package/functions/index.js.map +1 -1
  17. package/functions/log-level.d.ts +7 -0
  18. package/functions/log-level.js +42 -0
  19. package/functions/log-level.js.map +1 -0
  20. package/functions/merge-log-extras.d.ts +3 -0
  21. package/functions/merge-log-extras.js +31 -0
  22. package/functions/merge-log-extras.js.map +1 -0
  23. package/functions/parse-bulk-index-response.d.ts +4 -0
  24. package/functions/parse-bulk-index-response.js +40 -0
  25. package/functions/parse-bulk-index-response.js.map +1 -0
  26. package/functions/probe-log-store.d.ts +12 -0
  27. package/functions/probe-log-store.js +182 -0
  28. package/functions/probe-log-store.js.map +1 -0
  29. package/functions/serialize-log-for-persist.d.ts +4 -0
  30. package/functions/serialize-log-for-persist.js +54 -0
  31. package/functions/serialize-log-for-persist.js.map +1 -0
  32. package/functions/write-log-store-status.d.ts +5 -0
  33. package/functions/write-log-store-status.js +50 -0
  34. package/functions/write-log-store-status.js.map +1 -0
  35. package/index.d.ts +4 -0
  36. package/index.js +4 -0
  37. package/index.js.map +1 -1
  38. package/interfaces/log.d.ts +16 -0
  39. package/interfaces/log.js.map +1 -1
  40. package/logger.d.ts +9 -4
  41. package/logger.js +22 -9
  42. package/logger.js.map +1 -1
  43. package/package.json +33 -33
  44. package/services/log-runtime.service.d.ts +65 -0
  45. package/services/log-runtime.service.js +397 -0
  46. package/services/log-runtime.service.js.map +1 -0
  47. package/services/opensearch-client.d.ts +14 -0
  48. package/services/opensearch-client.js +113 -0
  49. package/services/opensearch-client.js.map +1 -0
  50. package/services/remote-persist.service.d.ts +31 -0
  51. package/services/remote-persist.service.js +261 -0
  52. package/services/remote-persist.service.js.map +1 -0
  53. package/stdout-writer.d.ts +6 -5
  54. package/stdout-writer.js +54 -44
  55. package/stdout-writer.js.map +1 -1
@@ -0,0 +1,14 @@
1
+ export interface RemotePersistConfig {
2
+ url: string;
3
+ appId: string;
4
+ index: string;
5
+ settingsIndex: string;
6
+ hooksIndex: string;
7
+ eventsIndex: string;
8
+ appsIndex: string;
9
+ username: string;
10
+ password: string;
11
+ spoolPath: string;
12
+ }
13
+ export declare const sanitizeIndexName: (index: string) => string;
14
+ export declare const readRemotePersistConfig: () => RemotePersistConfig | null;
@@ -0,0 +1,55 @@
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.readRemotePersistConfig = exports.sanitizeIndexName = void 0;
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const write_log_store_status_1 = require("../functions/write-log-store-status");
10
+ const sanitizeSlug = (value) => {
11
+ return value
12
+ .toLowerCase()
13
+ .replace(/[^a-z0-9-]+/g, '-')
14
+ .replace(/^-+|-+$/g, '')
15
+ || 'default';
16
+ };
17
+ const sanitizeIndexName = (index) => {
18
+ return sanitizeSlug(index);
19
+ };
20
+ exports.sanitizeIndexName = sanitizeIndexName;
21
+ const readRemotePersistConfig = () => {
22
+ var _a, _b, _c, _d, _e;
23
+ const enabled = parseBoolean(process.env.LOGGER_STORE_ENABLED);
24
+ if (!enabled) {
25
+ return null;
26
+ }
27
+ const url = (_a = process.env.LOGGER_STORE_URL) === null || _a === void 0 ? void 0 : _a.trim();
28
+ const appId = (_b = process.env.LOGGER_STORE_APP_ID) === null || _b === void 0 ? void 0 : _b.trim();
29
+ const index = (_c = process.env.LOGGER_STORE_INDEX) === null || _c === void 0 ? void 0 : _c.trim();
30
+ const username = (_d = process.env.LOGGER_STORE_USERNAME) === null || _d === void 0 ? void 0 : _d.trim();
31
+ const password = (_e = process.env.LOGGER_STORE_PASSWORD) === null || _e === void 0 ? void 0 : _e.trim();
32
+ if (!url || !appId || !index || !username || !password) {
33
+ (0, write_log_store_status_1.writeLogStoreConfigError)('Log store enabled but missing one or more required variables: '
34
+ + 'LOGGER_STORE_URL, LOGGER_STORE_APP_ID, LOGGER_STORE_INDEX, '
35
+ + 'LOGGER_STORE_USERNAME, LOGGER_STORE_PASSWORD');
36
+ return null;
37
+ }
38
+ const sanitizedAppId = sanitizeSlug(appId);
39
+ const sanitizedIndex = (0, exports.sanitizeIndexName)(index);
40
+ const spoolPath = path_1.default.join(os_1.default.tmpdir(), 'rockster-logger', 'spool', `${sanitizedAppId}.ndjson`);
41
+ return {
42
+ url: url.replace(/\/+$/, ''),
43
+ appId: sanitizedAppId,
44
+ index: sanitizedIndex,
45
+ settingsIndex: `${sanitizedIndex}-settings`,
46
+ hooksIndex: `${sanitizedIndex}-hooks`,
47
+ eventsIndex: `${sanitizedIndex}-events`,
48
+ appsIndex: `${sanitizedIndex}-apps`,
49
+ username,
50
+ password,
51
+ spoolPath,
52
+ };
53
+ };
54
+ exports.readRemotePersistConfig = readRemotePersistConfig;
55
+ //# sourceMappingURL=remote-persist.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-persist.config.js","sourceRoot":"","sources":["../../config/remote-persist.config.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,gFAA+E;AAe/E,MAAM,YAAY,GAAG,CAAC,KAAa,EAAU,EAAE;IAC5C,OAAO,KAAK;SACR,WA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K,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CACxB,YAAE,CAAC,MAAM,EAAE,EACX,iBAAiB,EACjB,OAAO,EACP,GAAG,cAAc,SAAS,CAC5B,CAAC;IAEF,OAAO;QACJ,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5B,KAAK,EAAE,cAAc;QACrB,KAAK,EAAE,cAAc;QACrB,aAAa,EAAE,GAAG,cAAc,WAAW;QAC3C,UAAU,EAAE,GAAG,cAAc,QAAQ;QACrC,WAAW,EAAE,GAAG,cAAc,SAAS;QACvC,SAAS,EAAE,GAAG,cAAc,OAAO;QACnC,QAAQ;QACR,QAAQ;QACR,SAAS;KACX,CAAC;AACL,CAAC,CAAC;AA1CW,QAAA,uBAAuB,2BA0ClC"}
package/env.js CHANGED
@@ -12,6 +12,8 @@ const interfaces_1 = require("./interfaces");
12
12
  const intercept_stdout_1 = __importDefault(require("intercept-stdout"));
13
13
  const functions_1 = require("./functions");
14
14
  const stdout_writer_1 = require("./stdout-writer");
15
+ const worker_threads_1 = require("worker_threads");
16
+ const remote_persist_service_1 = require("./services/remote-persist.service");
15
17
  exports.logEvent = 'onLog';
16
18
  exports.stdoutEvent = 'onStdout';
17
19
  global.logger = {
@@ -37,6 +39,20 @@ global.logger = {
37
39
  logger.emitter.on(exports.logEvent, (log) => {
38
40
  logger.history.logs.push(log);
39
41
  });
42
+ logger.emitter.on(exports.logEvent, (log) => {
43
+ (0, functions_1.dispatchLog)(log);
44
+ });
45
+ if (worker_threads_1.isMainThread) {
46
+ const remotePersist = (0, remote_persist_service_1.initRemotePersist)();
47
+ if (remotePersist) {
48
+ logger.emitter.on(exports.logEvent, (log) => {
49
+ if (!(0, functions_1.shouldDisplayLog)(log.type)) {
50
+ return;
51
+ }
52
+ remotePersist.enqueue(log);
53
+ });
54
+ }
55
+ }
40
56
  (0, functions_1.uncaughtException)((error) => {
41
57
  const isLogError = error.type === interfaces_1.LogType.error;
42
58
  const logError = !isLogError
@@ -44,9 +60,6 @@ logger.emitter.on(exports.logEvent, (log) => {
44
60
  : error;
45
61
  logError.stack = error.stack;
46
62
  logger.emitter.emit(exports.logEvent, logError);
47
- if (!logger.stdout.enabled) {
48
- logger.stdout.writer.write(logError);
49
- }
50
63
  });
51
64
  (0, functions_1.unhandledRejection)((error) => {
52
65
  const isLogError = error.type === interfaces_1.LogType.error;
@@ -55,8 +68,5 @@ logger.emitter.on(exports.logEvent, (log) => {
55
68
  : error;
56
69
  logError.stack = error.stack;
57
70
  logger.emitter.emit(exports.logEvent, logError);
58
- if (!logger.stdout.enabled) {
59
- logger.stdout.writer.write(logError);
60
- }
61
71
  });
62
72
  //# sourceMappingURL=env.js.map
package/env.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../env.ts"],"names":[],"mappings":";;;;;;AAAA,kCAAgC;AAChC,4BAA0B;AAC1B,kBAAgB;AAChB,mCAAsC;AACtC,6CAMsB;AACtB,wEAAyC;AACzC,2CAGqB;AACrB,mDAA+C;AAElC,QAAA,QAAQ,GAAG,OAAO,CAAC;AACnB,QAAA,WAAW,GAAG,UAAU,CAAC;AAyCtC,MAAM,CAAC,MAAM,GAAG;IACb,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,IAAI,qBAAY,EAAE;IAC3B,UAAU,EAAE,wBAAwB;IACpC,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE;QACN,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;KACZ;IACD,MAAM,EAAE;QACL,MAAM,EAAE,IAAI,4BAAY,EAAE;QAC1B,OAAO,EAAE,IAAI,qBAAY,EAAE;QAC3B,OAAO,EAAE,KAAK;KAChB;CACH,CAAC;AAEF,IAAA,0BAAS,EAAC,CAAC,KAAK,EAAE,EAAE;IACjB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAA0B,CAAC,CAAC;IACvD,MAAM,CA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C,OAAO,EACb,MAAM,EAAE,EACR,oBAAoB,CACtB;QACD,CAAC,CAAC,KAAK,CAAC;IACX,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC7B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAQ,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Log } from '../interfaces';
2
+ export declare const dispatchLog: (log: Log) => void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dispatchLog = void 0;
4
+ const interfaces_1 = require("../interfaces");
5
+ const log_level_1 = require("./log-level");
6
+ const dispatchLog = (log) => {
7
+ if (!(0, log_level_1.shouldDisplayLog)(log.type)) {
8
+ return;
9
+ }
10
+ const isError = log.type === interfaces_1.LogType.error;
11
+ if (!isError && !logger.stdout.enabled) {
12
+ return;
13
+ }
14
+ logger.stdout.writer.write(log);
15
+ };
16
+ exports.dispatchLog = dispatchLog;
17
+ //# sourceMappingURL=dispatch-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-log.js","sourceRoot":"","sources":["../../functions/dispatch-log.ts"],"names":[],"mappings":";;;AAAA,8CAA6C;AAC7C,2CAA+C;AAExC,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAQ,EAAE;IAC3C,IAAI,CAAC,IAAA,4BAAgB,EAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO;IACV,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,KAAK,oBAAO,CAAC,KAAK,CAAC;IAC3C,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtC,OAAO;IACV,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC;AAXW,QAAA,WAAW,eAWtB"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enableConsole = void 0;
4
- const env_1 = require("../env");
5
4
  const enableConsole = ({ appName, dateFormat }) => {
6
5
  if (logger.stdout.enabled) {
7
6
  return;
@@ -11,9 +10,6 @@ const enableConsole = ({ appName, dateFormat }) => {
11
10
  }
12
11
  logger.name = appName;
13
12
  logger.stdout.enabled = true;
14
- logger.emitter.on(env_1.logEvent, (log) => {
15
- logger.stdout.writer.write(log);
16
- });
17
13
  };
18
14
  exports.enableConsole = enableConsole;
19
15
  //# sourceMappingURL=enable-console.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enable-console.js","sourceRoot":"","sources":["../../functions/enable-console.ts"],"names":[],"mappings":";;;AAAA,gCAAkC;AAE3B,MAAM,aAAa,GAAG,CAAC,EAC3B,OAAO,EACP,UAAU,EAIZ,EAAE,EAAE;IAEF,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,OAAO;IACV,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACd,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;IACtB,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,cAAQ,EAAE,CAAC,GAAG,EAAE,EAAE;QACjC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACN,CAAC,CAAA;AArBY,QAAA,aAAa,iBAqBzB"}
1
+ {"version":3,"file":"enable-console.js","sourceRoot":"","sources":["../../functions/enable-console.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,EAC3B,OAAO,EACP,UAAU,EAIZ,EAAE,EAAE;IAEF,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,OAAO;IACV,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACd,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;IACtB,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;AAChC,CAAC,CAAC;AAlBW,QAAA,aAAa,iBAkBxB"}
@@ -1,4 +1,4 @@
1
- export declare const getErrorInfos: (error: Error, message?: string, parent?: string, values?: any) => {
1
+ export declare const getErrorInfos: (error: Error) => {
2
2
  message: string;
3
- values: any;
3
+ values: Record<string, unknown>;
4
4
  };
@@ -1,7 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getErrorInfos = void 0;
4
- const getErrorInfos = (error, message = '', parent = '', values = {}) => {
4
+ const DEFAULT_MAX_DEPTH = 12;
5
+ const deepCheck = (value, message = '', parent = '', values = {}, visited = new WeakSet(), depth = 0, maxDepth = DEFAULT_MAX_DEPTH) => {
6
+ if (value == null || typeof value !== 'object') {
7
+ return {
8
+ message: `${message}${parent}${String(value !== null && value !== void 0 ? value : 'unknown error')}\n`,
9
+ values,
10
+ };
11
+ }
12
+ if (visited.has(value)) {
13
+ values['[Circular]'] = true;
14
+ return { message, values };
15
+ }
16
+ if (depth >= maxDepth) {
17
+ values['[MaxDepth]'] = true;
18
+ return { message, values };
19
+ }
20
+ visited.add(value);
21
+ const error = value;
5
22
  const descriptors = Object.getOwnPropertyDescriptors(error);
6
23
  Object.getOwnPropertyNames(descriptors).forEach((property) => {
7
24
  values[property] = descriptors[property].value;
@@ -13,31 +30,41 @@ const getErrorInfos = (error, message = '', parent = '', values = {}) => {
13
30
  if (property === 'stack') {
14
31
  return;
15
32
  }
16
- if (Array.isArray(values[property])) {
17
- values[property].forEach((arrayItem, index) => {
18
- if (typeof (arrayItem) === 'object') {
19
- values[property][index] = {};
20
- const errorInfos = (0, exports.getErrorInfos)(arrayItem, message, `${parent}${property}[${index}].`, values[property][index]);
33
+ const current = values[property];
34
+ if (Array.isArray(current)) {
35
+ const arrayCopy = [];
36
+ values[property] = arrayCopy;
37
+ current.forEach((arrayItem, index) => {
38
+ if (arrayItem != null && typeof arrayItem === 'object') {
39
+ arrayCopy[index] = {};
40
+ const errorInfos = deepCheck(arrayItem, message, `${parent}${property}[${index}].`, arrayCopy[index], visited, depth + 1, maxDepth);
21
41
  message += errorInfos.message;
22
42
  }
23
43
  else {
44
+ arrayCopy[index] = arrayItem;
24
45
  message += `${arrayItem}\n`;
25
46
  }
26
47
  });
27
48
  }
28
- else if (typeof (values[property]) === 'object') {
49
+ else if (current != null && typeof current === 'object') {
50
+ const nested = current;
29
51
  values[property] = {};
30
- const errorInfos = (0, exports.getErrorInfos)(values[property], message, `${parent}${property}.`, values[property]);
52
+ const errorInfos = deepCheck(nested, message, `${parent}${property}.`, values[property], visited, depth + 1, maxDepth);
31
53
  message += errorInfos.message;
32
54
  }
33
55
  else {
34
- message += `${parent}${property}: ${values[property]}\n`;
56
+ message += `${parent}${property}: ${current}\n`;
35
57
  }
36
58
  });
37
- return {
38
- message,
39
- values
40
- };
59
+ if ('cause' in error && error.cause != null && !values.cause) {
60
+ values.cause = {};
61
+ const causeInfos = deepCheck(error.cause, message, `${parent}cause.`, values.cause, visited, depth + 1, maxDepth);
62
+ message += causeInfos.message;
63
+ }
64
+ return { message, values };
65
+ };
66
+ const getErrorInfos = (error) => {
67
+ return deepCheck(error);
41
68
  };
42
69
  exports.getErrorInfos = getErrorInfos;
43
70
  //# sourceMappingURL=get-error-infos.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-error-infos.js","sourceRoot":"","sources":["../../functions/get-error-infos.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAC1B,KAAY,EACZ,UAAkB,EAAE,EACpB,SAAiB,EAAE,EACnB,SAAc,EAAE,EACjB,EAAE;IACD,MAAM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T,QAAQ,CACV,CAAC;QACF,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC9B,CAAC,CAAC;AAEK,MAAM,aAAa,GAAG,CAC1B,KAAY,EACyC,EAAE;IACvD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB"}
@@ -3,3 +3,6 @@ export * from './is-development';
3
3
  export * from './uncaught-exception';
4
4
  export * from './unhandled-rejection';
5
5
  export * from './get-error-infos';
6
+ export * from './serialize-log-for-persist';
7
+ export * from './dispatch-log';
8
+ export * from './log-level';
@@ -19,4 +19,7 @@ __exportStar(require("./is-development"), exports);
19
19
  __exportStar(require("./uncaught-exception"), exports);
20
20
  __exportStar(require("./unhandled-rejection"), exports);
21
21
  __exportStar(require("./get-error-infos"), exports);
22
+ __exportStar(require("./serialize-log-for-persist"), exports);
23
+ __exportStar(require("./dispatch-log"), exports);
24
+ __exportStar(require("./log-level"), exports);
22
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,mDAAiC;AACjC,uDAAqC;AACrC,wDAAsC;AACtC,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,mDAAiC;AACjC,uDAAqC;AACrC,wDAAsC;AACtC,oDAAkC;AAClC,8DAA4C;AAC5C,iDAA+B;AAC/B,8CAA4B"}
@@ -0,0 +1,7 @@
1
+ import { LogLevel } from '@rockster/common/logs';
2
+ import { LogType } from '../interfaces';
3
+ export { LogLevel };
4
+ export declare const setRuntimeLogLevel: (level: LogLevel | null) => void;
5
+ export declare const getLogLevelFromEnv: () => LogLevel;
6
+ export declare const getLogLevel: () => LogLevel;
7
+ export declare const shouldDisplayLog: (type: LogType) => boolean;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldDisplayLog = exports.getLogLevel = exports.getLogLevelFromEnv = exports.setRuntimeLogLevel = exports.LogLevel = void 0;
4
+ const logs_1 = require("@rockster/common/logs");
5
+ Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return logs_1.LogLevel; } });
6
+ const interfaces_1 = require("../interfaces");
7
+ let runtimeLogLevel = null;
8
+ const setRuntimeLogLevel = (level) => {
9
+ runtimeLogLevel = level;
10
+ };
11
+ exports.setRuntimeLogLevel = setRuntimeLogLevel;
12
+ const getLogLevelFromEnv = () => {
13
+ var _a;
14
+ const raw = (_a = process.env.LOG_LEVEL) === null || _a === void 0 ? void 0 : _a.toLowerCase();
15
+ if (raw === logs_1.LogLevel.error || raw === logs_1.LogLevel.debug) {
16
+ return raw;
17
+ }
18
+ return logs_1.LogLevel.info;
19
+ };
20
+ exports.getLogLevelFromEnv = getLogLevelFromEnv;
21
+ const getLogLevel = () => {
22
+ if (runtimeLogLevel) {
23
+ return runtimeLogLevel;
24
+ }
25
+ return (0, exports.getLogLevelFromEnv)();
26
+ };
27
+ exports.getLogLevel = getLogLevel;
28
+ const shouldDisplayLog = (type) => {
29
+ if (type === interfaces_1.LogType.error) {
30
+ return true;
31
+ }
32
+ const level = (0, exports.getLogLevel)();
33
+ if (level === logs_1.LogLevel.error) {
34
+ return false;
35
+ }
36
+ if (level === logs_1.LogLevel.info) {
37
+ return type === interfaces_1.LogType.info;
38
+ }
39
+ return true;
40
+ };
41
+ exports.shouldDisplayLog = shouldDisplayLog;
42
+ //# sourceMappingURL=log-level.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-level.js","sourceRoot":"","sources":["../../functions/log-level.ts"],"names":[],"mappings":";;;AAAA,gDAAiD;AAGxC,yFAHA,eAAQ,OAGA;AAFjB,8CAA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are const RESERVED_LOG_PERSIST_KEYS: Set<string>;
3
+ export declare const mergeLogExtras: <T extends Record<string, unknown>>(base: T, extras?: LogExtras) => T & Record<string, LogExtraValue>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeLogExtras = exports.RESERVED_LOG_PERSIST_KEYS = void 0;
4
+ exports.RESERVED_LOG_PERSIST_KEYS = new Set([
5
+ 'type',
6
+ 'date',
7
+ 'context',
8
+ 'message',
9
+ 'duration',
10
+ 'stack',
11
+ 'error',
12
+ 'stdout',
13
+ 'pid',
14
+ 'hostname',
15
+ 'appId',
16
+ ]);
17
+ const mergeLogExtras = (base, extras) => {
18
+ if (!extras) {
19
+ return base;
20
+ }
21
+ const merged = Object.assign({}, base);
22
+ for (const [key, value] of Object.entries(extras)) {
23
+ if (exports.RESERVED_LOG_PERSIST_KEYS.has(key) || value === undefined) {
24
+ continue;
25
+ }
26
+ merged[key] = value;
27
+ }
28
+ return merged;
29
+ };
30
+ exports.mergeLogExtras = mergeLogExtras;
31
+ //# sourceMappingURL=merge-log-extras.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-log-extras.js","sourceRoot":"","sources":["../../functions/merge-log-extras.ts"],"names":[],"mappings":";;;AAEa,QAAA,yBAAyB,GAAG,IAAI,GAAG,CAAC;IAC9C,MAAM;IACN,MAAM;IACN,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,QAAQ;IACR,KAAK;IACL,UAAU;IACV,OAAO;CACT,CAAC,CAAC;AAEI,MAAM,cAAc,GAAG,CAC3B,IAAO,EACP,MAAkB,EACgB,EAAE;IACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACX,OAAO,IAAyC,CAAC;IACpD,CAAC;IAED,MAAM,MAAM,qBAAiC,IAAI,CAAE,CAAC;IACpD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,iCAAyB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7D,SAAS;QACZ,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC;IACD,OAAO,MAA2C,CAAC;AACtD,CAAC,CAAC;AAhBW,QAAA,cAAc,kBAgBzB"}
@@ -0,0 +1,4 @@
1
+ import { ILogPersisted } from '../interfaces';
2
+ export declare function bulkItemHttpStatus(item: unknown): number | null;
3
+ export declare function isBulkItemSuccess(status: number | null): boolean;
4
+ export declare function documentsFailedInBulkResponse(documents: ILogPersisted[], items: unknown[] | undefined, bulkHadErrors: boolean): ILogPersisted[];
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bulkItemHttpStatus = bulkItemHttpStatus;
4
+ exports.isBulkItemSuccess = isBulkItemSuccess;
5
+ exports.documentsFailedInBulkResponse = documentsFailedInBulkResponse;
6
+ function bulkItemHttpStatus(item) {
7
+ if (!item || typeof item !== 'object') {
8
+ return null;
9
+ }
10
+ const action = Object.values(item)[0];
11
+ if (!action || typeof action !== 'object') {
12
+ return null;
13
+ }
14
+ const status = action.status;
15
+ const code = typeof status === 'number' ? status : Number.parseInt(String(status !== null && status !== void 0 ? status : ''), 10);
16
+ return Number.isFinite(code) ? code : null;
17
+ }
18
+ function isBulkItemSuccess(status) {
19
+ return status != null && status >= 200 && status < 300;
20
+ }
21
+ function documentsFailedInBulkResponse(documents, items, bulkHadErrors) {
22
+ if (documents.length === 0) {
23
+ return [];
24
+ }
25
+ if (!bulkHadErrors) {
26
+ return [];
27
+ }
28
+ if (!(items === null || items === void 0 ? void 0 : items.length)) {
29
+ return [...documents];
30
+ }
31
+ const failed = [];
32
+ for (let i = 0; i < documents.length; i++) {
33
+ const status = bulkItemHttpStatus(items[i]);
34
+ if (!isBulkItemSuccess(status)) {
35
+ failed.push(documents[i]);
36
+ }
37
+ }
38
+ return failed;
39
+ }
40
+ //# sourceMappingURL=parse-bulk-index-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-bulk-index-response.js","sourceRoot":"","sources":["../../functions/parse-bulk-index-response.ts"],"names":[],"mappings":";;AAGA,gDAWC;AAED,8CAEC;AAKD,sEAuBC;AA3CD,SAAgB,kBAAkB,CAAC,IAAa;IAC7C,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAA+B,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAI,MAA+B,CAAC,MAAM,CAAC;IACvD,MAAM,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7F,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,CAAC;AAED,SAAgB,iBAAiB,CAAC,MAAqB;IACpD,OAAO,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC;AAC1D,CAAC;AAKD,SAAgB,6BAA6B,CAC1C,SAA0B,EAC1B,KAA4B,EAC5B,aAAsB;IAEtB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACb,CAAC;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACb,CAAC;IACD,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAA,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AACjB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { RemotePersistConfig } from '../config/remote-persist.config';
2
+ export type LogStoreProbeStep = {
3
+ name: string;
4
+ ok: boolean;
5
+ warning?: boolean;
6
+ detail: string;
7
+ };
8
+ export type LogStoreProbeReport = {
9
+ ok: boolean;
10
+ steps: LogStoreProbeStep[];
11
+ };
12
+ export declare const probeLogStore: (config: RemotePersistConfig) => Promise<LogStoreProbeReport>;