@nexload-sdk/logger 4.1.0 → 5.0.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 (58) hide show
  1. package/README.md +240 -34
  2. package/dist/config.d.ts +62 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/context.browser.d.ts +9 -0
  5. package/dist/context.browser.d.ts.map +1 -0
  6. package/dist/context.node.d.ts +6 -0
  7. package/dist/context.node.d.ts.map +1 -0
  8. package/dist/index.browser.d.ts +3 -0
  9. package/dist/index.browser.d.ts.map +1 -0
  10. package/dist/index.browser.mjs +1383 -0
  11. package/dist/index.browser.mjs.map +7 -0
  12. package/dist/index.cjs +236 -412
  13. package/dist/index.cjs.map +4 -4
  14. package/dist/index.d.ts +8 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.mjs +227 -409
  17. package/dist/index.mjs.map +4 -4
  18. package/dist/levels.d.ts +3 -0
  19. package/dist/levels.d.ts.map +1 -0
  20. package/dist/pretty.d.ts +4 -0
  21. package/dist/pretty.d.ts.map +1 -0
  22. package/dist/proxy.d.ts +3 -0
  23. package/dist/proxy.d.ts.map +1 -0
  24. package/dist/redact.d.ts +2 -0
  25. package/dist/redact.d.ts.map +1 -0
  26. package/dist/serialize-error.d.ts +2 -0
  27. package/dist/serialize-error.d.ts.map +1 -0
  28. package/dist/testing.cjs +206 -0
  29. package/dist/testing.cjs.map +7 -0
  30. package/dist/testing.d.ts +7 -0
  31. package/dist/testing.d.ts.map +1 -0
  32. package/dist/testing.mjs +168 -0
  33. package/dist/testing.mjs.map +7 -0
  34. package/dist/trace.d.ts +6 -0
  35. package/dist/trace.d.ts.map +1 -0
  36. package/dist/types.d.ts +39 -16
  37. package/dist/types.d.ts.map +1 -1
  38. package/package.json +17 -11
  39. package/dist/log-test.cjs +0 -102
  40. package/dist/log-test.cjs.map +0 -7
  41. package/dist/log-test.d.ts +0 -3
  42. package/dist/log-test.d.ts.map +0 -1
  43. package/dist/log-test.mjs +0 -78
  44. package/dist/log-test.mjs.map +0 -7
  45. package/dist/logger.d.ts +0 -20
  46. package/dist/logger.d.ts.map +0 -1
  47. package/dist/renderers/browser-pretty.d.ts +0 -12
  48. package/dist/renderers/browser-pretty.d.ts.map +0 -1
  49. package/dist/renderers/browser-pure.d.ts +0 -3
  50. package/dist/renderers/browser-pure.d.ts.map +0 -1
  51. package/dist/renderers/node-pretty.d.ts +0 -12
  52. package/dist/renderers/node-pretty.d.ts.map +0 -1
  53. package/dist/renderers/node-pure-json.d.ts +0 -3
  54. package/dist/renderers/node-pure-json.d.ts.map +0 -1
  55. package/dist/utils/create-global.d.ts +0 -3
  56. package/dist/utils/create-global.d.ts.map +0 -1
  57. package/dist/utils/json-humanize.d.ts +0 -2
  58. package/dist/utils/json-humanize.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/config.ts", "../src/context.node.ts", "../src/levels.ts", "../src/pretty.ts", "../src/redact.ts", "../src/serialize-error.ts", "../src/testing.ts"],
4
+ "sourcesContent": ["/* eslint-disable turbo/no-undeclared-env-vars -- These fallbacks are read at runtime, after the package build. */\n\nimport pino from \"pino\";\n\nimport type { Logger, LoggerOptions, LogLevel } from \"./types\";\n\nimport { getLogContext, isBrowser } from \"./context.node\";\nimport { LEVELS } from \"./levels\";\nimport { createPrettyStream } from \"./pretty\";\nimport { createProxy } from \"./proxy\";\nimport { DEFAULT_REDACT_PATHS } from \"./redact\";\nimport { serializeError } from \"./serialize-error\";\n\ntype PinoLogger = pino.Logger<\"success\">;\n\nexport type PayloadLoggerConfig = {\n options: ReturnType<typeof buildPinoOptions>;\n destination?: LoggerOptions[\"destination\"];\n};\n\nlet configured: { logger: PinoLogger; config: PayloadLoggerConfig } | undefined;\nlet fallbackLogger: PinoLogger | undefined;\nlet configuredProxy: Logger | undefined;\n\nfunction isLogLevel(value: string): value is LogLevel {\n return Object.prototype.hasOwnProperty.call(LEVELS, value);\n}\n\nfunction resolveLevel(): LogLevel {\n const level = process.env.LOG_LEVEL?.trim().toLowerCase();\n\n if (level && isLogLevel(level)) {\n return level;\n }\n\n return process.env.NODE_ENV === \"production\" ? \"info\" : \"debug\";\n}\n\nfunction buildPinoOptions(options: Partial<LoggerOptions>) {\n return {\n redact: { paths: [...(options.redact?.replaceDefaults ? [] : DEFAULT_REDACT_PATHS), ...(options.redact?.paths ?? [])], censor: options.redact?.censor ?? \"[REDACTED]\" },\n serializers: { err: serializeError },\n mixin: getLogContext,\n level: options.level ?? resolveLevel(),\n base: {\n ...options.base,\n service: options.service ?? process.env.SERVICE_NAME ?? \"unknown\",\n release: options.release ?? process.env.RELEASE,\n instance: options.instance,\n environment: options.environment,\n pid: process.pid,\n },\n timestamp: pino.stdTimeFunctions.isoTime,\n formatters: { level: (label) => ({ level: label }) },\n } satisfies pino.LoggerOptions;\n}\n\nexport function createPinoLogger(\n options: Partial<LoggerOptions>,\n sharedOptions = buildPinoOptions(options),\n): PinoLogger {\n const pinoOptions = {\n ...sharedOptions,\n customLevels: { success: LEVELS.success },\n useOnlyCustomLevels: false,\n };\n\n if (isBrowser) {\n return pino({\n ...pinoOptions,\n browser: {\n asObject: true,\n serialize: [\"err\", \"!stdSerializers.err\"],\n formatters: {\n level: pinoOptions.formatters.level,\n log: (record) => ({ ...pinoOptions.base, ...record }),\n },\n },\n });\n }\n\n const destination = options.destination ??\n ((options.pretty ?? process.env.NODE_ENV !== \"production\")\n ? createPrettyStream((line) => { process.stdout.write(line); })\n : undefined);\n\n return pino(pinoOptions, destination);\n}\n\nexport function configureLogger(options: LoggerOptions): Logger {\n if (configured && !options.force) {\n configured.logger\n .child({}, { level: \"warn\" })\n .warn(\n { event: \"logger.reconfigure.ignored\" },\n \"Logger is already configured\",\n );\n\n return (configuredProxy ??= createProxy());\n }\n\n const sharedOptions = buildPinoOptions(options);\n configured = {\n logger: createPinoLogger(options, sharedOptions),\n config: { options: sharedOptions, destination: options.destination },\n };\n fallbackLogger = undefined;\n\n return (configuredProxy ??= createProxy());\n}\n\nexport function getActiveLogger(): PinoLogger {\n return configured?.logger ?? (fallbackLogger ??= createPinoLogger({}));\n}\n\nexport function getPayloadLoggerConfig(): PayloadLoggerConfig {\n const { options, destination } = configured?.config ?? {\n options: buildPinoOptions({}),\n };\n\n return {\n options: {\n ...options,\n level: options.level === \"success\" ? \"warn\" : options.level,\n redact: { ...options.redact, paths: [...options.redact.paths] },\n serializers: { ...options.serializers },\n base: { ...options.base },\n formatters: { ...options.formatters },\n },\n ...(destination === undefined ? {} : { destination }),\n };\n}\n", "import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport type { LogBindings } from \"./types\";\n\nexport { randomUUID as newTraceId } from \"node:crypto\";\nexport const isBrowser: boolean = false;\n\n// Share context across the independently bundled root and testing entries.\nconst contextKey = Symbol.for(\"@nexload-sdk/logger/context\");\nconst runtime = globalThis as typeof globalThis & {\n [contextKey]?: AsyncLocalStorage<LogBindings>;\n};\nconst context = (runtime[contextKey] ??= new AsyncLocalStorage<LogBindings>());\n\nexport function withLogContext<T>(bindings: LogBindings, fn: () => T): T {\n return context.run({ ...context.getStore(), ...bindings }, fn);\n}\n\nexport function getLogContext(): LogBindings {\n // Pino mutates the mixin result when merging per-call fields.\n return { ...context.getStore() };\n}\n", "import type { LogLevel } from \"./types\";\n\nexport const LEVELS: Record<LogLevel, number> = {\n trace: 10,\n debug: 20,\n info: 30,\n success: 35,\n warn: 40,\n error: 50,\n fatal: 60,\n};\n", "const COLORS: Record<string, number> = {\n trace: 90, debug: 36, info: 34, success: 32, warn: 33, error: 31, fatal: 35,\n};\n\nexport function createPrettyStream(write: (text: string) => void): { write(line: string): void } {\n return {\n write(line) {\n const record = JSON.parse(line) as Record<string, unknown>;\n const { time, level, service, msg, err, ...fields } = record;\n const date = new Date(String(time));\n const clock = Number.isNaN(date.getTime()) ? '--:--:--' : date.toTimeString().slice(0, 8);\n const label = String(level ?? '').toUpperCase();\n const color = COLORS[String(level)];\n const formattedLevel = process.stdout.isTTY && color ? `\\u001b[${color}m${label}\\u001b[0m` : label;\n const values = Object.entries(fields).map(([key, value]) => `${key}=${typeof value === 'string' ? value : JSON.stringify(value)}`);\n let output = [clock, formattedLevel, service, msg, ...values].filter((part) => part !== undefined && part !== '').join(' ');\n\n if (err && typeof err === 'object') {\n const error = err as { type?: unknown; message?: unknown; stack?: unknown };\n output += ` ${String(error.type ?? 'Error')}: ${String(error.message ?? '')}`;\n if (typeof error.stack === 'string') {\n const lines = error.stack.split('\\n');\n output += `\\n${lines.slice(1).join('\\n')}`;\n }\n }\n write(`${output}\\n`);\n },\n };\n}\n", "const keys = [\"password\", \"token\", \"secret\", \"apiKey\", \"authorization\", \"cookie\", \"otp\", \"phone\", \"mobile\", \"merchant\"];\n\nexport const DEFAULT_REDACT_PATHS: readonly string[] = [\n ...keys.flatMap((key) => [key, `*.${key}`]),\n \"req.headers.authorization\", \"req.headers.cookie\", \"headers.authorization\", \"headers.cookie\", \"body\", \"req.body\",\n];\n", "/* eslint-disable turbo/no-undeclared-env-vars -- Runtime controls stack visibility. */\nexport function serializeError(error: unknown, depth = 0): Record<string, unknown> {\n if (!(error instanceof Error)) {\n return { type: typeof error, message: String(error).slice(0, 500) };\n }\n\n const result: Record<string, unknown> = {\n type: error.name,\n message: error.message.slice(0, 500),\n };\n const code = (error as Error & { code?: unknown }).code;\n\n if (typeof code === \"string\" && /^[A-Z][A-Z0-9_]{1,99}$/.test(code)) result.code = code;\n if (process.env.NODE_ENV !== \"production\" && error.stack) result.stack = error.stack;\n if (error.cause !== undefined && depth < 2) result.cause = serializeError(error.cause, depth + 1);\n\n return result;\n}\n", "import type { LogEntry, Logger, LoggerOptions } from \"./types\";\n\nimport { createPinoLogger } from \"./config\";\n\nexport function createTestLogger(options: Partial<LoggerOptions> = {}): {\n logger: Logger;\n entries: LogEntry[];\n clear(): void;\n} {\n const entries: LogEntry[] = [];\n const logger = createPinoLogger({\n ...options,\n destination: {\n write(line) {\n entries.push(JSON.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MAAI,WAAW;AACb,WAAO,KAAK;AAAA,MACV,GAAG;AAAA,MACH,SAAS;AAAA,QACP,UAAU;AAAA,QACV,WAAW,CAAC,OAAO,qBAAqB;AAAA,QACxC,YAAY;AAAA,UACV,OAAO,YAAY,WAAW;AAAA,UAC9B,KAAK,CAAC,YAAY,EAAE,GAAG,YAAY,MAAM,GAAG,OAAO;AAAA,QACrD;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,cAAc,QAAQ,gBACxB,QAAQ,UAAU,QAAQ,IAAI,aAAa,eACzC,mBAAmB,CAAC,SAAS;AAAE,YAAQ,OAAO,MAAM,IAAI;AAAA,EAAG,CAAC,IAC5D;AAEN,SAAO,KAAK,aAAa,WAAW;AACtC;;;AMnFO,SAAS,iBAAiB,UAAkC,CAAC,GAIlE;AACA,QAAM,UAAsB,CAAC;AAC7B,QAAM,SAAS,iBAAiB;AAAA,IAC9B,GAAG;AAAA,IACH,aAAa;AAAA,MACX,MAAM,MAAM;AACV,gBAAQ,KAAK,KAAK,MAAM,IAAI,CAAa;AAAA,MAC3C;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,QAAQ;AACN,cAAQ,SAAS;AAAA,IACnB;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ export declare const TRACE_HEADER = "x-trace-id";
2
+ type HeaderRecord = Record<string, string | undefined>;
3
+ export declare function resolveTraceId(headers: Headers | HeaderRecord): string;
4
+ export declare function traceHeaders(): Record<string, string>;
5
+ export {};
6
+ //# sourceMappingURL=trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,eAAe,CAAC;AAGzC,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAMvD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,MAAM,CAItE;AAED,wBAAgB,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMrD"}
package/dist/types.d.ts CHANGED
@@ -1,18 +1,41 @@
1
- export type LogLevel = "TRACE" | "INFO" | "SUCCESS" | "WARN" | "ERROR" | "FATAL" | "DEBUG";
2
- export type LogRendererFunc = (line: object) => void;
3
- export type LogRenderer = {
4
- node: LogRendererFunc;
5
- browser: LogRendererFunc;
6
- };
7
- export declare const isBrowser: () => boolean;
8
- export declare const isNode: () => boolean;
9
- export declare const levelPriorities: {
10
- readonly FATAL: 70;
11
- readonly ERROR: 60;
12
- readonly WARN: 50;
13
- readonly SUCCESS: 40;
14
- readonly INFO: 30;
15
- readonly DEBUG: 20;
16
- readonly TRACE: 10;
1
+ export type LogLevel = "trace" | "debug" | "info" | "success" | "warn" | "error" | "fatal";
2
+ export type LogBindings = Record<string, unknown>;
3
+ export type LogEntry = {
4
+ level: LogLevel;
5
+ time: string;
6
+ service: string;
7
+ msg?: string;
8
+ [key: string]: unknown;
17
9
  };
10
+ type LogMethod = (objOrMsg?: object | Error | string, msg?: string) => void;
11
+ export interface Logger {
12
+ trace: LogMethod;
13
+ debug: LogMethod;
14
+ info: LogMethod;
15
+ success: LogMethod;
16
+ warn: LogMethod;
17
+ error: LogMethod;
18
+ fatal: LogMethod;
19
+ child(bindings: LogBindings): Logger;
20
+ isLevelEnabled(level: LogLevel): boolean;
21
+ }
22
+ export interface LoggerOptions {
23
+ service: string;
24
+ level?: LogLevel;
25
+ release?: string;
26
+ instance?: string;
27
+ environment?: string;
28
+ redact?: {
29
+ paths?: string[];
30
+ replaceDefaults?: boolean;
31
+ censor?: string;
32
+ };
33
+ pretty?: boolean;
34
+ destination?: {
35
+ write(line: string): void;
36
+ };
37
+ base?: Record<string, string | number | boolean>;
38
+ force?: boolean;
39
+ }
40
+ export {};
18
41
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAChB,OAAO,GACP,MAAM,GACN,SAAS,GACT,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,CAAC;AACZ,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AACrD,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAE9E,eAAO,MAAM,SAAS,eAC4C,CAAC;AACnE,eAAO,MAAM,MAAM,eAAuC,CAAC;AAC3D,eAAO,MAAM,eAAe;;;;;;;;CAQlB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAChB,OAAO,GACP,OAAO,GACP,MAAM,GACN,SAAS,GACT,MAAM,GACN,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,SAAS,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAE5E,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAAC;IACrC,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC1C;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE;QAAE,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexload-sdk/logger",
3
- "version": "4.1.0",
4
- "description": "High-performance, structured, and type-safe logging for JS/TS apps — powered by pino, with pretty output, env-integration, security redaction, and Next.js-friendly wrappers.",
3
+ "version": "5.0.0",
4
+ "description": "Configure-once structured logger for Node, Edge and browser, built on pino, with safe defaults.",
5
5
  "keywords": [
6
6
  "logger",
7
7
  "pino",
@@ -10,7 +10,6 @@
10
10
  "structured log",
11
11
  "nextjs",
12
12
  "nodejs",
13
- "pretty print",
14
13
  "redact",
15
14
  "performance",
16
15
  "observability"
@@ -34,15 +33,18 @@
34
33
  "exports": {
35
34
  ".": {
36
35
  "types": "./dist/index.d.ts",
36
+ "browser": "./dist/index.browser.mjs",
37
+ "edge-light": "./dist/index.browser.mjs",
38
+ "worker": "./dist/index.browser.mjs",
37
39
  "import": "./dist/index.mjs",
38
40
  "require": "./dist/index.cjs",
39
41
  "default": "./dist/index.mjs"
40
42
  },
41
- "./log-test": {
42
- "types": "./dist/log-test.d.ts",
43
- "import": "./dist/log-test.mjs",
44
- "require": "./dist/log-test.cjs",
45
- "default": "./dist/log-test.mjs"
43
+ "./testing": {
44
+ "types": "./dist/testing.d.ts",
45
+ "import": "./dist/testing.mjs",
46
+ "require": "./dist/testing.cjs",
47
+ "default": "./dist/testing.mjs"
46
48
  }
47
49
  },
48
50
  "files": [
@@ -59,11 +61,15 @@
59
61
  "eslint": "^9.39.2",
60
62
  "typescript": "5.9.3",
61
63
  "@nexload-sdk/bundler": "4.0.1",
62
- "@nexload-sdk/eslint-config": "4.0.1",
63
- "@nexload-sdk/typescript-config": "4.0.1"
64
+ "@nexload-sdk/eslint-config": "9.39.2",
65
+ "@nexload-sdk/typescript-config": "5.9.3"
66
+ },
67
+ "dependencies": {
68
+ "pino": "^10.4.0"
64
69
  },
65
70
  "scripts": {
66
71
  "lint": "eslint .",
67
- "build": "node esbuild.config.mjs"
72
+ "build": "node esbuild.config.mjs",
73
+ "test": "pnpm build && node --test test/*.test.mjs"
68
74
  }
69
75
  }
package/dist/log-test.cjs DELETED
@@ -1,102 +0,0 @@
1
- // @nexload-sdk/logger v4.0.1 (build 2026-07-20T16:45:36.833Z)
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/log-test.ts
22
- var log_test_exports = {};
23
- __export(log_test_exports, {
24
- test: () => test
25
- });
26
- module.exports = __toCommonJS(log_test_exports);
27
- async function test(logger) {
28
- const processId = Math.floor(Math.random() * 1e4);
29
- logger.trace(
30
- { pid: processId, memory: 80 },
31
- "Process started, initializing modules..."
32
- );
33
- const config = { db: "mongo:27017", timeout: 5e3, retries: 3 };
34
- logger.debug({ config }, "Configuration loaded successfully");
35
- logger.info(
36
- { dbHost: config.db, poolSize: 10 },
37
- "Attempting to connect to Database..."
38
- );
39
- await new Promise((r) => setTimeout(r, 100));
40
- logger.success(
41
- { latency_ms: 45, status: "connected" },
42
- "Database connection established"
43
- );
44
- const orders = [
45
- { id: 101, amount: 500, user: "ali" },
46
- { id: 102, amount: 0, user: "bot" },
47
- // Invalid
48
- { id: 103, amount: 12e3, user: "sara" }
49
- ];
50
- logger.info({ batchSize: orders.length }, "Starting batch order processing");
51
- for (const order of orders) {
52
- logger.trace({ orderId: order.id }, "Processing order item");
53
- if (order.amount <= 0) {
54
- logger.warn(
55
- { orderId: order.id, userId: order.user, amount: order.amount },
56
- "Skipping invalid order amount"
57
- );
58
- continue;
59
- }
60
- logger.info(
61
- {
62
- orderId: order.id,
63
- transactionId: `tx_${Math.random().toString(36).substring(7)}`
64
- },
65
- "Order processed"
66
- );
67
- }
68
- try {
69
- simulateCriticalFailure();
70
- } catch (err) {
71
- logger.error(
72
- {
73
- errorName: err.name,
74
- errorMessage: err.message,
75
- stack: err.stack,
76
- // لاگر باید بتواند استک‌تریس را هندل کند
77
- failedModule: "PaymentGateway"
78
- },
79
- "Transaction failed unexpectedly"
80
- );
81
- }
82
- const heapTotal = 80;
83
- const heapLimit = 1024 * 1024 * 500;
84
- if (heapTotal < heapLimit) {
85
- logger.fatal(
86
- {
87
- usage: heapTotal,
88
- limit: heapLimit,
89
- action: "graceful_shutdown"
90
- },
91
- "CRITICAL: Memory leak detected, shutting down service!"
92
- );
93
- }
94
- }
95
- function simulateCriticalFailure() {
96
- throw new Error("Connection ECONNREFUSED 127.0.0.1:8080");
97
- }
98
- // Annotate the CommonJS export names for ESM import in node:
99
- 0 && (module.exports = {
100
- test
101
- });
102
- //# sourceMappingURL=log-test.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/log-test.ts"],
4
- "sourcesContent": ["import type { NexloadLogger } from \"./logger\";\n\nexport async function test(logger: NexloadLogger) {\n const processId = Math.floor(Math.random() * 10000);\n\n // ---------------------------------------------------------\n // 1. System Startup (Boot Sequence) - TRACE / DEBUG\n // ---------------------------------------------------------\n logger.trace(\n { pid: processId, memory: 80 },\n \"Process started, initializing modules...\"\n );\n\n // \u0634\u0628\u06CC\u0647\u200C\u0633\u0627\u0632\u06CC \u062E\u0648\u0627\u0646\u062F\u0646 \u06A9\u0627\u0646\u0641\u06CC\u06AF\n const config = { db: \"mongo:27017\", timeout: 5000, retries: 3 };\n logger.debug({ config }, \"Configuration loaded successfully\");\n\n // ---------------------------------------------------------\n // 2. Database Connection - INFO / SUCCESS\n // ---------------------------------------------------------\n logger.info(\n { dbHost: config.db, poolSize: 10 },\n \"Attempting to connect to Database...\"\n );\n\n // \u0634\u0628\u06CC\u0647\u200C\u0633\u0627\u0632\u06CC \u062A\u0627\u062E\u06CC\u0631 \u0627\u062A\u0635\u0627\u0644\n await new Promise((r) => setTimeout(r, 100));\n\n logger.success(\n { latency_ms: 45, status: \"connected\" },\n \"Database connection established\"\n );\n\n // ---------------------------------------------------------\n // 3. Batch Processing Simulation (High Volume) - TRACE / INFO\n // ---------------------------------------------------------\n const orders = [\n { id: 101, amount: 500, user: \"ali\" },\n { id: 102, amount: 0, user: \"bot\" }, // Invalid\n { id: 103, amount: 12000, user: \"sara\" },\n ];\n\n logger.info({ batchSize: orders.length }, \"Starting batch order processing\");\n\n for (const order of orders) {\n // \u0644\u0627\u06AF \u0628\u0633\u06CC\u0627\u0631 \u062C\u0632\u0626\u06CC \u0628\u0631\u0627\u06CC \u062F\u06CC\u0628\u0627\u06AF \u06A9\u0631\u062F\u0646 \u0644\u0648\u067E\u200C\u0647\u0627\n logger.trace({ orderId: order.id }, \"Processing order item\");\n\n if (order.amount <= 0) {\n // ---------------------------------------------------------\n // 4. Validation Logic - WARN\n // ---------------------------------------------------------\n logger.warn(\n { orderId: order.id, userId: order.user, amount: order.amount },\n \"Skipping invalid order amount\"\n );\n continue;\n }\n\n // \u0639\u0645\u0644\u06CC\u0627\u062A \u0645\u0648\u0641\u0642\u06CC\u062A\u200C\u0622\u0645\u06CC\u0632\n logger.info(\n {\n orderId: order.id,\n transactionId: `tx_${Math.random().toString(36).substring(7)}`,\n },\n \"Order processed\"\n );\n }\n\n // ---------------------------------------------------------\n // 5. Error Handling Simulation - ERROR\n // ---------------------------------------------------------\n try {\n // \u0634\u0628\u06CC\u0647\u200C\u0633\u0627\u0632\u06CC \u06CC\u06A9 \u062E\u0637\u0627\u06CC \u063A\u06CC\u0631\u0645\u0646\u062A\u0638\u0631\u0647\n simulateCriticalFailure();\n } catch (err: any) {\n // \u067E\u0627\u0633 \u062F\u0627\u062F\u0646 \u0622\u0628\u062C\u06A9\u062A \u062E\u0637\u0627 \u0628\u0647 \u0644\u0627\u06AF\u0631\n logger.error(\n {\n errorName: err.name,\n errorMessage: err.message,\n stack: err.stack, // \u0644\u0627\u06AF\u0631 \u0628\u0627\u06CC\u062F \u0628\u062A\u0648\u0627\u0646\u062F \u0627\u0633\u062A\u06A9\u200C\u062A\u0631\u06CC\u0633 \u0631\u0627 \u0647\u0646\u062F\u0644 \u06A9\u0646\u062F\n failedModule: \"PaymentGateway\",\n },\n \"Transaction failed unexpectedly\"\n );\n }\n\n // ---------------------------------------------------------\n // 6. Critical System Failure - FATAL\n // ---------------------------------------------------------\n // \u0634\u0631\u0627\u06CC\u0637\u06CC \u06A9\u0647 \u0633\u0631\u0648\u06CC\u0633 \u062F\u06CC\u06AF\u0631 \u0646\u0645\u06CC\u200C\u062A\u0648\u0627\u0646\u062F \u0627\u062F\u0627\u0645\u0647 \u062F\u0647\u062F\n const heapTotal = 80;\n const heapLimit = 1024 * 1024 * 500; // \u0641\u0631\u0636 500MB\n\n if (heapTotal < heapLimit) {\n // \u0634\u0631\u0637 \u0646\u0645\u0627\u06CC\u0634\u06CC\n logger.fatal(\n {\n usage: heapTotal,\n limit: heapLimit,\n action: \"graceful_shutdown\",\n },\n \"CRITICAL: Memory leak detected, shutting down service!\"\n );\n }\n}\n\n// Helper to throw error\nfunction simulateCriticalFailure() {\n throw new Error(\"Connection ECONNREFUSED 127.0.0.1:8080\");\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,eAAsB,KAAK,QAAuB;AAChD,QAAM,YAAY,KAAK,MAAM,KAAK,OAAO,IAAI,GAAK;AAKlD,SAAO;AAAA,IACL,EAAE,KAAK,WAAW,QAAQ,GAAG;AAAA,IAC7B;AAAA,EACF;AAGA,QAAM,SAAS,EAAE,IAAI,eAAe,SAAS,KAAM,SAAS,EAAE;AAC9D,SAAO,MAAM,EAAE,OAAO,GAAG,mCAAmC;AAK5D,SAAO;AAAA,IACL,EAAE,QAAQ,OAAO,IAAI,UAAU,GAAG;AAAA,IAClC;AAAA,EACF;AAGA,QAAM,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAE3C,SAAO;AAAA,IACL,EAAE,YAAY,IAAI,QAAQ,YAAY;AAAA,IACtC;AAAA,EACF;AAKA,QAAM,SAAS;AAAA,IACb,EAAE,IAAI,KAAK,QAAQ,KAAK,MAAM,MAAM;AAAA,IACpC,EAAE,IAAI,KAAK,QAAQ,GAAG,MAAM,MAAM;AAAA;AAAA,IAClC,EAAE,IAAI,KAAK,QAAQ,MAAO,MAAM,OAAO;AAAA,EACzC;AAEA,SAAO,KAAK,EAAE,WAAW,OAAO,OAAO,GAAG,iCAAiC;AAE3E,aAAW,SAAS,QAAQ;AAE1B,WAAO,MAAM,EAAE,SAAS,MAAM,GAAG,GAAG,uBAAuB;AAE3D,QAAI,MAAM,UAAU,GAAG;AAIrB,aAAO;AAAA,QACL,EAAE,SAAS,MAAM,IAAI,QAAQ,MAAM,MAAM,QAAQ,MAAM,OAAO;AAAA,QAC9D;AAAA,MACF;AACA;AAAA,IACF;AAGA,WAAO;AAAA,MACL;AAAA,QACE,SAAS,MAAM;AAAA,QACf,eAAe,MAAM,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC;AAAA,MAC9D;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAKA,MAAI;AAEF,4BAAwB;AAAA,EAC1B,SAAS,KAAU;AAEjB,WAAO;AAAA,MACL;AAAA,QACE,WAAW,IAAI;AAAA,QACf,cAAc,IAAI;AAAA,QAClB,OAAO,IAAI;AAAA;AAAA,QACX,cAAc;AAAA,MAChB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAMA,QAAM,YAAY;AAClB,QAAM,YAAY,OAAO,OAAO;AAEhC,MAAI,YAAY,WAAW;AAEzB,WAAO;AAAA,MACL;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAGA,SAAS,0BAA0B;AACjC,QAAM,IAAI,MAAM,wCAAwC;AAC1D;",
6
- "names": []
7
- }
@@ -1,3 +0,0 @@
1
- import type { NexloadLogger } from "./logger";
2
- export declare function test(logger: NexloadLogger): Promise<void>;
3
- //# sourceMappingURL=log-test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"log-test.d.ts","sourceRoot":"","sources":["../src/log-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAsB,IAAI,CAAC,MAAM,EAAE,aAAa,iBAwG/C"}
package/dist/log-test.mjs DELETED
@@ -1,78 +0,0 @@
1
- // @nexload-sdk/logger v4.0.1 (build 2026-07-20T16:45:35.965Z)
2
-
3
- // src/log-test.ts
4
- async function test(logger) {
5
- const processId = Math.floor(Math.random() * 1e4);
6
- logger.trace(
7
- { pid: processId, memory: 80 },
8
- "Process started, initializing modules..."
9
- );
10
- const config = { db: "mongo:27017", timeout: 5e3, retries: 3 };
11
- logger.debug({ config }, "Configuration loaded successfully");
12
- logger.info(
13
- { dbHost: config.db, poolSize: 10 },
14
- "Attempting to connect to Database..."
15
- );
16
- await new Promise((r) => setTimeout(r, 100));
17
- logger.success(
18
- { latency_ms: 45, status: "connected" },
19
- "Database connection established"
20
- );
21
- const orders = [
22
- { id: 101, amount: 500, user: "ali" },
23
- { id: 102, amount: 0, user: "bot" },
24
- // Invalid
25
- { id: 103, amount: 12e3, user: "sara" }
26
- ];
27
- logger.info({ batchSize: orders.length }, "Starting batch order processing");
28
- for (const order of orders) {
29
- logger.trace({ orderId: order.id }, "Processing order item");
30
- if (order.amount <= 0) {
31
- logger.warn(
32
- { orderId: order.id, userId: order.user, amount: order.amount },
33
- "Skipping invalid order amount"
34
- );
35
- continue;
36
- }
37
- logger.info(
38
- {
39
- orderId: order.id,
40
- transactionId: `tx_${Math.random().toString(36).substring(7)}`
41
- },
42
- "Order processed"
43
- );
44
- }
45
- try {
46
- simulateCriticalFailure();
47
- } catch (err) {
48
- logger.error(
49
- {
50
- errorName: err.name,
51
- errorMessage: err.message,
52
- stack: err.stack,
53
- // لاگر باید بتواند استک‌تریس را هندل کند
54
- failedModule: "PaymentGateway"
55
- },
56
- "Transaction failed unexpectedly"
57
- );
58
- }
59
- const heapTotal = 80;
60
- const heapLimit = 1024 * 1024 * 500;
61
- if (heapTotal < heapLimit) {
62
- logger.fatal(
63
- {
64
- usage: heapTotal,
65
- limit: heapLimit,
66
- action: "graceful_shutdown"
67
- },
68
- "CRITICAL: Memory leak detected, shutting down service!"
69
- );
70
- }
71
- }
72
- function simulateCriticalFailure() {
73
- throw new Error("Connection ECONNREFUSED 127.0.0.1:8080");
74
- }
75
- export {
76
- test
77
- };
78
- //# sourceMappingURL=log-test.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/log-test.ts"],
4
- "sourcesContent": ["import type { NexloadLogger } from \"./logger\";\n\nexport async function test(logger: NexloadLogger) {\n const processId = Math.floor(Math.random() * 10000);\n\n // ---------------------------------------------------------\n // 1. System Startup (Boot Sequence) - TRACE / DEBUG\n // ---------------------------------------------------------\n logger.trace(\n { pid: processId, memory: 80 },\n \"Process started, initializing modules...\"\n );\n\n // \u0634\u0628\u06CC\u0647\u200C\u0633\u0627\u0632\u06CC \u062E\u0648\u0627\u0646\u062F\u0646 \u06A9\u0627\u0646\u0641\u06CC\u06AF\n const config = { db: \"mongo:27017\", timeout: 5000, retries: 3 };\n logger.debug({ config }, \"Configuration loaded successfully\");\n\n // ---------------------------------------------------------\n // 2. Database Connection - INFO / SUCCESS\n // ---------------------------------------------------------\n logger.info(\n { dbHost: config.db, poolSize: 10 },\n \"Attempting to connect to Database...\"\n );\n\n // \u0634\u0628\u06CC\u0647\u200C\u0633\u0627\u0632\u06CC \u062A\u0627\u062E\u06CC\u0631 \u0627\u062A\u0635\u0627\u0644\n await new Promise((r) => setTimeout(r, 100));\n\n logger.success(\n { latency_ms: 45, status: \"connected\" },\n \"Database connection established\"\n );\n\n // ---------------------------------------------------------\n // 3. Batch Processing Simulation (High Volume) - TRACE / INFO\n // ---------------------------------------------------------\n const orders = [\n { id: 101, amount: 500, user: \"ali\" },\n { id: 102, amount: 0, user: \"bot\" }, // Invalid\n { id: 103, amount: 12000, user: \"sara\" },\n ];\n\n logger.info({ batchSize: orders.length }, \"Starting batch order processing\");\n\n for (const order of orders) {\n // \u0644\u0627\u06AF \u0628\u0633\u06CC\u0627\u0631 \u062C\u0632\u0626\u06CC \u0628\u0631\u0627\u06CC \u062F\u06CC\u0628\u0627\u06AF \u06A9\u0631\u062F\u0646 \u0644\u0648\u067E\u200C\u0647\u0627\n logger.trace({ orderId: order.id }, \"Processing order item\");\n\n if (order.amount <= 0) {\n // ---------------------------------------------------------\n // 4. Validation Logic - WARN\n // ---------------------------------------------------------\n logger.warn(\n { orderId: order.id, userId: order.user, amount: order.amount },\n \"Skipping invalid order amount\"\n );\n continue;\n }\n\n // \u0639\u0645\u0644\u06CC\u0627\u062A \u0645\u0648\u0641\u0642\u06CC\u062A\u200C\u0622\u0645\u06CC\u0632\n logger.info(\n {\n orderId: order.id,\n transactionId: `tx_${Math.random().toString(36).substring(7)}`,\n },\n \"Order processed\"\n );\n }\n\n // ---------------------------------------------------------\n // 5. Error Handling Simulation - ERROR\n // ---------------------------------------------------------\n try {\n // \u0634\u0628\u06CC\u0647\u200C\u0633\u0627\u0632\u06CC \u06CC\u06A9 \u062E\u0637\u0627\u06CC \u063A\u06CC\u0631\u0645\u0646\u062A\u0638\u0631\u0647\n simulateCriticalFailure();\n } catch (err: any) {\n // \u067E\u0627\u0633 \u062F\u0627\u062F\u0646 \u0622\u0628\u062C\u06A9\u062A \u062E\u0637\u0627 \u0628\u0647 \u0644\u0627\u06AF\u0631\n logger.error(\n {\n errorName: err.name,\n errorMessage: err.message,\n stack: err.stack, // \u0644\u0627\u06AF\u0631 \u0628\u0627\u06CC\u062F \u0628\u062A\u0648\u0627\u0646\u062F \u0627\u0633\u062A\u06A9\u200C\u062A\u0631\u06CC\u0633 \u0631\u0627 \u0647\u0646\u062F\u0644 \u06A9\u0646\u062F\n failedModule: \"PaymentGateway\",\n },\n \"Transaction failed unexpectedly\"\n );\n }\n\n // ---------------------------------------------------------\n // 6. Critical System Failure - FATAL\n // ---------------------------------------------------------\n // \u0634\u0631\u0627\u06CC\u0637\u06CC \u06A9\u0647 \u0633\u0631\u0648\u06CC\u0633 \u062F\u06CC\u06AF\u0631 \u0646\u0645\u06CC\u200C\u062A\u0648\u0627\u0646\u062F \u0627\u062F\u0627\u0645\u0647 \u062F\u0647\u062F\n const heapTotal = 80;\n const heapLimit = 1024 * 1024 * 500; // \u0641\u0631\u0636 500MB\n\n if (heapTotal < heapLimit) {\n // \u0634\u0631\u0637 \u0646\u0645\u0627\u06CC\u0634\u06CC\n logger.fatal(\n {\n usage: heapTotal,\n limit: heapLimit,\n action: \"graceful_shutdown\",\n },\n \"CRITICAL: Memory leak detected, shutting down service!\"\n );\n }\n}\n\n// Helper to throw error\nfunction simulateCriticalFailure() {\n throw new Error(\"Connection ECONNREFUSED 127.0.0.1:8080\");\n}\n"],
5
- "mappings": ";;;AAEA,eAAsB,KAAK,QAAuB;AAChD,QAAM,YAAY,KAAK,MAAM,KAAK,OAAO,IAAI,GAAK;AAKlD,SAAO;AAAA,IACL,EAAE,KAAK,WAAW,QAAQ,GAAG;AAAA,IAC7B;AAAA,EACF;AAGA,QAAM,SAAS,EAAE,IAAI,eAAe,SAAS,KAAM,SAAS,EAAE;AAC9D,SAAO,MAAM,EAAE,OAAO,GAAG,mCAAmC;AAK5D,SAAO;AAAA,IACL,EAAE,QAAQ,OAAO,IAAI,UAAU,GAAG;AAAA,IAClC;AAAA,EACF;AAGA,QAAM,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAE3C,SAAO;AAAA,IACL,EAAE,YAAY,IAAI,QAAQ,YAAY;AAAA,IACtC;AAAA,EACF;AAKA,QAAM,SAAS;AAAA,IACb,EAAE,IAAI,KAAK,QAAQ,KAAK,MAAM,MAAM;AAAA,IACpC,EAAE,IAAI,KAAK,QAAQ,GAAG,MAAM,MAAM;AAAA;AAAA,IAClC,EAAE,IAAI,KAAK,QAAQ,MAAO,MAAM,OAAO;AAAA,EACzC;AAEA,SAAO,KAAK,EAAE,WAAW,OAAO,OAAO,GAAG,iCAAiC;AAE3E,aAAW,SAAS,QAAQ;AAE1B,WAAO,MAAM,EAAE,SAAS,MAAM,GAAG,GAAG,uBAAuB;AAE3D,QAAI,MAAM,UAAU,GAAG;AAIrB,aAAO;AAAA,QACL,EAAE,SAAS,MAAM,IAAI,QAAQ,MAAM,MAAM,QAAQ,MAAM,OAAO;AAAA,QAC9D;AAAA,MACF;AACA;AAAA,IACF;AAGA,WAAO;AAAA,MACL;AAAA,QACE,SAAS,MAAM;AAAA,QACf,eAAe,MAAM,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC;AAAA,MAC9D;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAKA,MAAI;AAEF,4BAAwB;AAAA,EAC1B,SAAS,KAAU;AAEjB,WAAO;AAAA,MACL;AAAA,QACE,WAAW,IAAI;AAAA,QACf,cAAc,IAAI;AAAA,QAClB,OAAO,IAAI;AAAA;AAAA,QACX,cAAc;AAAA,MAChB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAMA,QAAM,YAAY;AAClB,QAAM,YAAY,OAAO,OAAO;AAEhC,MAAI,YAAY,WAAW;AAEzB,WAAO;AAAA,MACL;AAAA,QACE,OAAO;AAAA,QACP,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAGA,SAAS,0BAA0B;AACjC,QAAM,IAAI,MAAM,wCAAwC;AAC1D;",
6
- "names": []
7
- }
package/dist/logger.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { LogLevel, LogRenderer } from "./types";
2
- export declare class NexloadLogger {
3
- readonly name: string;
4
- readonly level: LogLevel;
5
- protected readonly renderer: LogRenderer;
6
- protected baseObject: object;
7
- private readonly threshold;
8
- constructor(name: string, level: LogLevel, renderer: LogRenderer, baseObject?: object);
9
- private normalizeInput;
10
- private dispatch;
11
- child(obj?: object): NexloadLogger;
12
- trace(objOrMsg?: object | string, msg?: string): void;
13
- debug(objOrMsg?: object | string, msg?: string): void;
14
- info(objOrMsg?: object | string, msg?: string): void;
15
- success(objOrMsg?: object | string, msg?: string): void;
16
- warn(objOrMsg?: object | string, msg?: string): void;
17
- error(objOrMsg?: object | string, msg?: string): void;
18
- fatal(objOrMsg?: object | string, msg?: string): void;
19
- }
20
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EACR,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,qBAAa,aAAa;aAIN,IAAI,EAAE,MAAM;aACZ,KAAK,EAAE,QAAQ;IAC/B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW;IACxC,SAAS,CAAC,UAAU,EAAE,MAAM;IAN9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAGjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,QAAQ,EACZ,QAAQ,EAAE,WAAW,EAC9B,UAAU,GAAE,MAAW;IAMnC,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,QAAQ;IA0BT,KAAK,CAAC,GAAG,GAAE,MAAW,GAAG,aAAa;IAOtC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAGrD,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAGrD,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAGpD,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAGvD,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAGpD,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAGrD,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;CAG7D"}
@@ -1,12 +0,0 @@
1
- import { LogRendererFunc } from "@/types";
2
- export declare const levelSymbols: {
3
- readonly TRACE: "›";
4
- readonly DEBUG: "•";
5
- readonly INFO: "ℹ";
6
- readonly SUCCESS: "✔";
7
- readonly WARN: "⚠";
8
- readonly ERROR: "✗";
9
- readonly FATAL: "✝";
10
- };
11
- export declare const browserPrettyRenderer: LogRendererFunc;
12
- //# sourceMappingURL=browser-pretty.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser-pretty.d.ts","sourceRoot":"","sources":["../../src/renderers/browser-pretty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAepD,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAC;AAEX,eAAO,MAAM,qBAAqB,EAAE,eAkBnC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { LogRendererFunc } from "@/types";
2
- export declare const browserPureRenderer: LogRendererFunc;
3
- //# sourceMappingURL=browser-pure.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser-pure.d.ts","sourceRoot":"","sources":["../../src/renderers/browser-pure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,mBAAmB,EAAE,eA2BjC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { LogRendererFunc } from "@/types";
2
- export declare const levelSymbols: {
3
- readonly TRACE: "›";
4
- readonly DEBUG: "•";
5
- readonly INFO: "ℹ";
6
- readonly SUCCESS: "✔";
7
- readonly WARN: "⚠";
8
- readonly ERROR: "✗";
9
- readonly FATAL: "✝";
10
- };
11
- export declare const nodePrettyRenderer: LogRendererFunc;
12
- //# sourceMappingURL=node-pretty.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-pretty.d.ts","sourceRoot":"","sources":["../../src/renderers/node-pretty.ts"],"names":[],"mappings":"AAaA,OAAO,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAYpD,eAAO,MAAM,YAAY;;;;;;;;CAQf,CAAC;AAoBX,eAAO,MAAM,kBAAkB,EAAE,eAqChC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { LogRendererFunc } from "@/types";
2
- export declare const nodePureJsonRenderer: LogRendererFunc;
3
- //# sourceMappingURL=node-pure-json.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-pure-json.d.ts","sourceRoot":"","sources":["../../src/renderers/node-pure-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAC;AAE7D,eAAO,MAAM,oBAAoB,EAAE,eAIlC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { NexloadLogger } from "@/logger";
2
- export declare const createGlobalLogger: () => NexloadLogger;
3
- //# sourceMappingURL=create-global.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-global.d.ts","sourceRoot":"","sources":["../../src/utils/create-global.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA0DzC,eAAO,MAAM,kBAAkB,qBACoC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function jsonHumanize(data: any, indentLevel?: number): string;
2
- //# sourceMappingURL=json-humanize.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-humanize.d.ts","sourceRoot":"","sources":["../../src/utils/json-humanize.ts"],"names":[],"mappings":"AA4BA,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,SAAI,GAAG,MAAM,CAkC/D"}