logs-gateway 3.2.0 → 3.5.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.
- package/README.md +1255 -1263
- package/dist/formatters/yaml-formatter.d.ts.map +1 -1
- package/dist/formatters/yaml-formatter.js +39 -10
- package/dist/formatters/yaml-formatter.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +3 -14
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +64 -120
- package/dist/logger.js.map +1 -1
- package/dist/sanitizer.d.ts +7 -0
- package/dist/sanitizer.d.ts.map +1 -1
- package/dist/sanitizer.js +40 -24
- package/dist/sanitizer.js.map +1 -1
- package/dist/types.d.ts +10 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/debug-config.d.ts.map +1 -1
- package/dist/utils/debug-config.js +3 -66
- package/dist/utils/debug-config.js.map +1 -1
- package/dist/utils/package-logs-level.d.ts +40 -0
- package/dist/utils/package-logs-level.d.ts.map +1 -0
- package/dist/utils/package-logs-level.js +79 -0
- package/dist/utils/package-logs-level.js.map +1 -0
- package/docs/package-usage.md +155 -0
- package/docs/package.md +48 -0
- package/package.json +95 -94
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Package-level log threshold via `<packagePrefix>_LOGS_LEVEL` (canonical contract).
|
|
4
|
+
* See docs/package-usage.md in this package.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.packageLogsLevelEnvKey = packageLogsLevelEnvKey;
|
|
8
|
+
exports.legacyPackageLogLevelEnvKey = legacyPackageLogLevelEnvKey;
|
|
9
|
+
exports.parsePackageLogsLevelString = parsePackageLogsLevelString;
|
|
10
|
+
exports.resolvePackageLogsLevel = resolvePackageLogsLevel;
|
|
11
|
+
const OFF_SYNONYMS = new Set(['off', 'none', 'silent']);
|
|
12
|
+
const LEVEL_ALIASES = {
|
|
13
|
+
verbose: 'verbose',
|
|
14
|
+
debug: 'debug',
|
|
15
|
+
info: 'info',
|
|
16
|
+
warn: 'warn',
|
|
17
|
+
error: 'error'
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Environment variable name for the canonical package log threshold: `<PREFIX>_LOGS_LEVEL`.
|
|
21
|
+
*/
|
|
22
|
+
function packageLogsLevelEnvKey(envPrefix) {
|
|
23
|
+
return `${envPrefix}_LOGS_LEVEL`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Legacy env var: `<PREFIX>_LOG_LEVEL` (still supported when `_LOGS_LEVEL` is unset).
|
|
27
|
+
*/
|
|
28
|
+
function legacyPackageLogLevelEnvKey(envPrefix) {
|
|
29
|
+
return `${envPrefix}_LOG_LEVEL`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse a single value (case-insensitive). Unknown values are treated as disabled (off).
|
|
33
|
+
* Empty or whitespace-only string is treated as off.
|
|
34
|
+
*/
|
|
35
|
+
function parsePackageLogsLevelString(raw) {
|
|
36
|
+
if (raw === undefined) {
|
|
37
|
+
return { packageLogsDisabled: true };
|
|
38
|
+
}
|
|
39
|
+
const n = raw.trim().toLowerCase();
|
|
40
|
+
if (n.length === 0 || OFF_SYNONYMS.has(n)) {
|
|
41
|
+
return { packageLogsDisabled: true };
|
|
42
|
+
}
|
|
43
|
+
const level = LEVEL_ALIASES[n];
|
|
44
|
+
if (level) {
|
|
45
|
+
return { packageLogsDisabled: false, logLevel: level };
|
|
46
|
+
}
|
|
47
|
+
return { packageLogsDisabled: true };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve package log threshold for a logger instance.
|
|
51
|
+
*
|
|
52
|
+
* Precedence: `userLogLevel` → `<PREFIX>_LOGS_LEVEL` (if set in env) → `<PREFIX>_LOG_LEVEL` (legacy, if set) → **`warn`** (neither key set in env).
|
|
53
|
+
*
|
|
54
|
+
* When silent, `logLevel` in the result is `'error'` as a placeholder for internal storage; emission is gated by `packageLogsDisabled`.
|
|
55
|
+
*/
|
|
56
|
+
function resolvePackageLogsLevel(options) {
|
|
57
|
+
const { envPrefix, userLogLevel, env = process.env } = options;
|
|
58
|
+
if (userLogLevel !== undefined) {
|
|
59
|
+
return { packageLogsDisabled: false, logLevel: userLogLevel };
|
|
60
|
+
}
|
|
61
|
+
const logsKey = packageLogsLevelEnvKey(envPrefix);
|
|
62
|
+
const legacyKey = legacyPackageLogLevelEnvKey(envPrefix);
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(env, logsKey)) {
|
|
64
|
+
const parsed = parsePackageLogsLevelString(env[logsKey]);
|
|
65
|
+
if (parsed.packageLogsDisabled || !parsed.logLevel) {
|
|
66
|
+
return { packageLogsDisabled: true, logLevel: 'error' };
|
|
67
|
+
}
|
|
68
|
+
return { packageLogsDisabled: false, logLevel: parsed.logLevel };
|
|
69
|
+
}
|
|
70
|
+
if (Object.prototype.hasOwnProperty.call(env, legacyKey)) {
|
|
71
|
+
const parsed = parsePackageLogsLevelString(env[legacyKey]);
|
|
72
|
+
if (parsed.packageLogsDisabled || !parsed.logLevel) {
|
|
73
|
+
return { packageLogsDisabled: true, logLevel: 'error' };
|
|
74
|
+
}
|
|
75
|
+
return { packageLogsDisabled: false, logLevel: parsed.logLevel };
|
|
76
|
+
}
|
|
77
|
+
return { packageLogsDisabled: false, logLevel: 'warn' };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=package-logs-level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-logs-level.js","sourceRoot":"","sources":["../../src/utils/package-logs-level.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiBH,wDAEC;AAKD,kEAEC;AAMD,kEAgBC;AAiBD,0DA6BC;AA1FD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EA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diagnostics through **[logs-gateway](https://www.npmjs.com/package/logs-gateway)**.
|
|
4
|
+
|
|
5
|
+
- **Per package:** only **logs level** is configured with that package’s **package prefix** on the variable name.
|
|
6
|
+
- **Cross-cutting (once per app / process):** where logs go (console, file, unified, …) and **format** are **not** repeated per package—they are shared for the whole host. Downstream wiring implements that split; this doc defines the **package-level** part only.
|
|
7
|
+
|
|
8
|
+
**Default when neither `<packagePrefix>_LOGS_LEVEL` nor `<packagePrefix>_LOG_LEVEL` is set in the environment:** **`warn`** (emit **`warn`** and **`error`** only). To silence a package, set **`off`** (or synonyms **`none`** / **`silent`**). To see **`info`**, **`debug`**, or **`verbose`**, raise the level explicitly.
|
|
9
|
+
|
|
10
|
+
**Package prefix** is the short token a package owns for its **single** logs-gateway-related variable in this contract (illustrative examples: **`MY_LIB`**, **`EXAMPLE_SVC`**). Each package documents its own prefix in its README.
|
|
11
|
+
|
|
12
|
+
**logs-gateway** implements this contract inside `createLogger` / `LogsGateway`. It also exposes **`resolvePackageLogsLevel`**, **`parsePackageLogsLevelString`**, **`packageLogsLevelEnvKey`**, and **`legacyPackageLogLevelEnvKey`** for the same rules outside the gateway if needed.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## For package authors — how to implement
|
|
17
|
+
|
|
18
|
+
1. **Depend on** `logs-gateway` (normal `dependencies` for a library that logs).
|
|
19
|
+
2. **Choose a stable prefix** (short acronym, not the full scoped npm name). Use the same string for **`envPrefix`** and for documenting the env var (e.g. **`MY_LIB`** → **`MY_LIB_LOGS_LEVEL`**).
|
|
20
|
+
3. **Create one logger** (or one per logical surface, each with its own prefix if you truly need separate toggles—usually one prefix per package):
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { createLogger } from 'logs-gateway';
|
|
24
|
+
|
|
25
|
+
export const logger = createLogger({
|
|
26
|
+
packageName: 'MyLib', // label in log lines
|
|
27
|
+
envPrefix: 'MY_LIB', // reads MY_LIB_LOGS_LEVEL / MY_LIB_LOG_LEVEL
|
|
28
|
+
debugNamespace: 'my-lib' // optional: DEBUG namespace
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
4. **Emit using gateway levels** — `logger.error`, `logger.warn`, `logger.info`, `logger.debug`, `logger.verbose`. What actually appears is filtered by the resolved **minimum level** (see table below).
|
|
33
|
+
5. **Document for consumers** in your README: the prefix, the exact key **`<prefix>_LOGS_LEVEL`**, allowed values, and that **default is `warn`** if the variable is not set (and legacy **`_LOG_LEVEL`** is not set).
|
|
34
|
+
6. **Optional programmatic default** — pass **`logLevel`** in the second argument to **`createLogger`** only when you need a non-env default (it overrides env for that instance).
|
|
35
|
+
|
|
36
|
+
You do **not** need to read **`process.env`** for the level yourself if you use **`createLogger`** / **`LogsGateway`**; resolution is built in.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## For apps and operators — downstream (different levels per package)
|
|
41
|
+
|
|
42
|
+
Integrators tune **verbosity per dependency** by setting **one variable per package prefix** in **`.env`** (or the host’s secret/config store). That flows **downstream** into each library’s logger without code changes:
|
|
43
|
+
|
|
44
|
+
```dotenv
|
|
45
|
+
# Quieter third-party package; louder in-house library
|
|
46
|
+
EXAMPLE_GATEWAY_LOGS_LEVEL=error
|
|
47
|
+
MY_LIB_LOGS_LEVEL=info
|
|
48
|
+
|
|
49
|
+
# Turn one package off entirely
|
|
50
|
+
OTHER_PKG_LOGS_LEVEL=off
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Cross-cutting knobs (**where** logs go, **format**, file paths, unified sink, etc.) are configured **once** for the host (see logs-gateway README), not duplicated per package prefix.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 1. Package-level variable (only): `<packagePrefix>_LOGS_LEVEL`
|
|
58
|
+
|
|
59
|
+
```dotenv
|
|
60
|
+
MY_LIB_LOGS_LEVEL=warn
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Pattern: **`<packagePrefix>_LOGS_LEVEL`**.
|
|
64
|
+
|
|
65
|
+
- If **both** **`<packagePrefix>_LOGS_LEVEL`** and **`<packagePrefix>_LOG_LEVEL`** are **absent** from the environment, **logs-gateway** uses **`warn`** as the effective threshold.
|
|
66
|
+
- **`off`** (or **`none`** / **`silent`**) means that package does **not** emit diagnostic logs (regardless of cross-cutting sink configuration).
|
|
67
|
+
|
|
68
|
+
No other **package-prefixed** `.env` keys are part of this contract—**not** `<packagePrefix>_LOG_TO_CONSOLE`, `<packagePrefix>_LOG_TO_FILE`, `<packagePrefix>_LOG_FORMAT`, etc. Those belong to **cross-cutting** configuration.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 2. Allowed values for `<packagePrefix>_LOGS_LEVEL`
|
|
73
|
+
|
|
74
|
+
| Value | Meaning |
|
|
75
|
+
|--------|---------|
|
|
76
|
+
| **`off`** | Package diagnostics disabled (`none` / `silent` are synonyms). |
|
|
77
|
+
| **`error`** | Emit **`error`** only. |
|
|
78
|
+
| **`warn`** | Emit **`warn`** and **`error`**. |
|
|
79
|
+
| **`info`** | Emit **`info`** and above. |
|
|
80
|
+
| **`debug`** | Emit **`debug`** and above. |
|
|
81
|
+
| **`verbose`** | Most verbose. |
|
|
82
|
+
|
|
83
|
+
**Default when the env keys are not set:** **`warn`** (see §1).
|
|
84
|
+
|
|
85
|
+
Case-insensitive values are recommended; **logs-gateway** normalizes case when parsing.
|
|
86
|
+
|
|
87
|
+
Unknown values are treated as **`off`** (silent) in **logs-gateway**.
|
|
88
|
+
|
|
89
|
+
**Precedence in env:** if **both** **`_LOGS_LEVEL`** and **`_LOG_LEVEL`** are set, **`_LOGS_LEVEL`** wins. If only **`_LOG_LEVEL`** is set (legacy), it is used the same way as **`_LOGS_LEVEL`**.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 3. Cross-cutting configuration (shared across packages)
|
|
94
|
+
|
|
95
|
+
**Console, file, log file path, text/json/table format, unified logger, and similar** are **application- or host-level** concerns. They apply **once** to the process, not once per library prefix.
|
|
96
|
+
|
|
97
|
+
- A package with **`_LOGS_LEVEL=off`** must not emit diagnostics; host settings do not override that.
|
|
98
|
+
- When the package level is not **`off`**, lines use the **same** shared sinks and format as other packages that are allowed to emit.
|
|
99
|
+
|
|
100
|
+
Exact host variable names are in **logs-gateway** and application docs; they are not **`<packagePrefix>_…`** patterns in this contract.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 4. Choosing the package prefix
|
|
105
|
+
|
|
106
|
+
- Prefer a **stable acronym or short name**, not the full scoped npm name.
|
|
107
|
+
- Example (illustrative): **`@acme/example-lib`** might use **`EXAMPLE_LIB`**—pick one and keep it.
|
|
108
|
+
|
|
109
|
+
Document the prefix and **`<prefix>_LOGS_LEVEL`** in the package README.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 5. Example `.env` (placeholders)
|
|
114
|
+
|
|
115
|
+
**Per package (levels only):**
|
|
116
|
+
|
|
117
|
+
```dotenv
|
|
118
|
+
MY_LIB_LOGS_LEVEL=warn
|
|
119
|
+
EXAMPLE_GATEWAY_LOGS_LEVEL=info
|
|
120
|
+
|
|
121
|
+
# Silence or debug one layer
|
|
122
|
+
OTHER_PKG_LOGS_LEVEL=off
|
|
123
|
+
MY_LIB_LOGS_LEVEL=debug
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Cross-cutting (illustrative—host / logs-gateway global keys):**
|
|
127
|
+
|
|
128
|
+
```dotenv
|
|
129
|
+
# LOG_TO_CONSOLE=true
|
|
130
|
+
# LOG_FORMAT=json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 6. Interaction with process-wide `DEBUG`
|
|
136
|
+
|
|
137
|
+
Some stacks use **`DEBUG`** (comma-separated namespaces). That is separate from this contract:
|
|
138
|
+
|
|
139
|
+
- **`_LOGS_LEVEL=off`** stays authoritative: the package stays silent in **logs-gateway**.
|
|
140
|
+
- **`DEBUG`** can still allow **`verbose`** / **`debug`** lines **only when the package is not silent** (`packageLogsDisabled` is false). See **logs-gateway** README for details.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 7. Summary
|
|
145
|
+
|
|
146
|
+
| Layer | What is configured |
|
|
147
|
+
|--------|-------------------|
|
|
148
|
+
| **Per package** | **Only** `<packagePrefix>_LOGS_LEVEL` (default **`warn`** when both `_LOGS_LEVEL` and `_LOG_LEVEL` are unset in the environment) |
|
|
149
|
+
| **Cross-cutting** | Console, file, format, unified sink, etc.—**once** for the app / process |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 8. Migration note
|
|
154
|
+
|
|
155
|
+
If you relied on older behavior where **no** env vars implied **silent** output, set **`{PREFIX}_LOGS_LEVEL=off`** explicitly, or **`{PREFIX}_LOG_LEVEL=off`** if you only use the legacy key.
|
package/docs/package.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
**don’t use CommonJS** 🙂
|
|
2
|
+
|
|
3
|
+
### Use **ESM only**
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"compilerOptions": {
|
|
8
|
+
"target": "ES2022",
|
|
9
|
+
"module": "NodeNext",
|
|
10
|
+
"moduleResolution": "NodeNext"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Why this is the *right* choice **now**
|
|
16
|
+
|
|
17
|
+
* **Native ESM everywhere** (Node 18/20+, Bun, Deno, modern bundlers)
|
|
18
|
+
* Clean `import` / `export`, no interop hacks
|
|
19
|
+
* Future-proof for:
|
|
20
|
+
|
|
21
|
+
* tree-shaking
|
|
22
|
+
* edge / workers
|
|
23
|
+
* package `exports`
|
|
24
|
+
* Matches how *new* libraries are written in 2025–2026
|
|
25
|
+
|
|
26
|
+
### What *not* to do
|
|
27
|
+
|
|
28
|
+
* ❌ `"module": "commonjs"` → legacy, friction, dead-end
|
|
29
|
+
* ❌ `"module": "ES2020"` without `NodeNext` → subtle resolution bugs with Node ESM
|
|
30
|
+
|
|
31
|
+
### Minimal `package.json` you should use
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"type": "module",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": "./dist/index.js"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### One important rule (don’t trip on this)
|
|
43
|
+
|
|
44
|
+
* Use **explicit file extensions** in imports:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { x } from "./utils.js";
|
|
48
|
+
```
|
package/package.json
CHANGED
|
@@ -1,94 +1,95 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "logs-gateway",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Standardized logging gateway for Node.js with PII sanitization, correlation trails, Shadow Logging for test/debug capture, scoping with text filters, story output, troubleshooting integration, and multi-format output (JSON/YAML/text)",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"dev": "tsc --watch",
|
|
10
|
-
"clean": "rimraf dist",
|
|
11
|
-
"test": "vitest",
|
|
12
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
13
|
-
"generate-erc": "tsx scripts/generate-erc-manifest.ts"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"logging",
|
|
17
|
-
"logger",
|
|
18
|
-
"typescript",
|
|
19
|
-
"node",
|
|
20
|
-
"console",
|
|
21
|
-
"file",
|
|
22
|
-
"json",
|
|
23
|
-
"yaml",
|
|
24
|
-
"sanitization",
|
|
25
|
-
"pii",
|
|
26
|
-
"security",
|
|
27
|
-
"privacy",
|
|
28
|
-
"shadow-logging",
|
|
29
|
-
"debug-capture",
|
|
30
|
-
"test-logging",
|
|
31
|
-
"correlation",
|
|
32
|
-
"tracing",
|
|
33
|
-
"opentelemetry",
|
|
34
|
-
"trails",
|
|
35
|
-
"scoping",
|
|
36
|
-
"troubleshooting",
|
|
37
|
-
"story-output",
|
|
38
|
-
"scope-record"
|
|
39
|
-
],
|
|
40
|
-
"author": "nx-morpheus",
|
|
41
|
-
"license": "MIT",
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "git+https://github.com/nx-intelligence/logs-gateway.git"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://github.com/nx-intelligence/logs-gateway#readme",
|
|
47
|
-
"bugs": {
|
|
48
|
-
"url": "https://github.com/nx-intelligence/logs-gateway/issues"
|
|
49
|
-
},
|
|
50
|
-
"files": [
|
|
51
|
-
"dist/**/*",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"pino
|
|
66
|
-
"pino-
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"@types/
|
|
75
|
-
"@types/
|
|
76
|
-
"@types/
|
|
77
|
-
"@types/
|
|
78
|
-
"@types/
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "logs-gateway",
|
|
3
|
+
"version": "3.5.0",
|
|
4
|
+
"description": "Standardized logging gateway for Node.js with PII sanitization, correlation trails, Shadow Logging for test/debug capture, scoping with text filters, story output, troubleshooting integration, and multi-format output (JSON/YAML/text)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"clean": "rimraf dist",
|
|
11
|
+
"test": "vitest",
|
|
12
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
13
|
+
"generate-erc": "tsx scripts/generate-erc-manifest.ts"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"logging",
|
|
17
|
+
"logger",
|
|
18
|
+
"typescript",
|
|
19
|
+
"node",
|
|
20
|
+
"console",
|
|
21
|
+
"file",
|
|
22
|
+
"json",
|
|
23
|
+
"yaml",
|
|
24
|
+
"sanitization",
|
|
25
|
+
"pii",
|
|
26
|
+
"security",
|
|
27
|
+
"privacy",
|
|
28
|
+
"shadow-logging",
|
|
29
|
+
"debug-capture",
|
|
30
|
+
"test-logging",
|
|
31
|
+
"correlation",
|
|
32
|
+
"tracing",
|
|
33
|
+
"opentelemetry",
|
|
34
|
+
"trails",
|
|
35
|
+
"scoping",
|
|
36
|
+
"troubleshooting",
|
|
37
|
+
"story-output",
|
|
38
|
+
"scope-record"
|
|
39
|
+
],
|
|
40
|
+
"author": "nx-morpheus",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/nx-intelligence/logs-gateway.git"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/nx-intelligence/logs-gateway#readme",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/nx-intelligence/logs-gateway/issues"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist/**/*",
|
|
52
|
+
"docs/**/*",
|
|
53
|
+
"README.md",
|
|
54
|
+
"LICENSE"
|
|
55
|
+
],
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@cdssnc/sanitize-pii": "^2.0.3",
|
|
58
|
+
"@x-developer/unified-logger": "^1.0.15",
|
|
59
|
+
"consola": "^3.4.2",
|
|
60
|
+
"fast-redact": "^3.5.0",
|
|
61
|
+
"js-yaml": "^4.1.0",
|
|
62
|
+
"micro-logs": "^1.0.0",
|
|
63
|
+
"nanoid": "^5.1.6",
|
|
64
|
+
"nx-config2": "^3.5.0",
|
|
65
|
+
"pino": "^10.1.0",
|
|
66
|
+
"pino-http": "^11.0.0",
|
|
67
|
+
"pino-pretty": "^13.1.2",
|
|
68
|
+
"rotating-file-stream": "^3.2.7",
|
|
69
|
+
"validator": "^13.15.15",
|
|
70
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
71
|
+
"xss": "^1.0.15"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@types/fast-redact": "^3.0.4",
|
|
75
|
+
"@types/js-yaml": "^4.0.9",
|
|
76
|
+
"@types/nanoid": "^2.1.0",
|
|
77
|
+
"@types/node": "^20.0.0",
|
|
78
|
+
"@types/pino": "^7.0.4",
|
|
79
|
+
"@types/validator": "^13.15.3",
|
|
80
|
+
"rimraf": "^6.0.1",
|
|
81
|
+
"tsx": "^4.7.0",
|
|
82
|
+
"typescript": "^5.0.0",
|
|
83
|
+
"vitest": "^4.0.3"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"nx-troubleshooting": "^2.0.1"
|
|
87
|
+
},
|
|
88
|
+
"optionalDependencies": {
|
|
89
|
+
"nx-troubleshooting": "^2.0.1"
|
|
90
|
+
},
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": ">=16.0.0"
|
|
93
|
+
},
|
|
94
|
+
"type": "commonjs"
|
|
95
|
+
}
|