syntropylog 0.9.14 → 0.9.16
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/CHANGELOG.md +17 -0
- package/README.md +9 -13
- package/dist/index.cjs +55 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.mjs +55 -40
- package/dist/index.mjs.map +1 -1
- package/dist/logger/transports/optionalChalk.js +55 -40
- package/dist/logger/transports/optionalChalk.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/logger/transports/BaseConsolePrettyTransport.d.ts +1 -1
- package/dist/types/logger/transports/optionalChalk.d.ts +5 -6
- package/package.json +1 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Fix: Maximum call stack size exceeded in optionalChalk**
|
|
8
|
+
- `createChain()` was eagerly building all chain nodes when constructing the root, causing infinite recursion (each node created 12 more). Replaced direct property assignment with lazy getters so the next chain is only created when a property is accessed (e.g. `.red.bold`). Fixes runtime error when using ClassicConsoleTransport and other pretty transports.
|
|
9
|
+
- Added `examples/AllTransportsExample.ts` to validate all console transports (JSON, Classic, Pretty, Compact, Colorful) in one run.
|
|
10
|
+
|
|
11
|
+
## 0.9.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- **Built-in ANSI colors: remove chalk dependency**
|
|
16
|
+
- Pretty console transports (Classic, Pretty, Compact, Colorful) now use a built-in chalk-like API implemented with ANSI escape codes. No chalk peer dependency.
|
|
17
|
+
- Colors are disabled when `NO_COLOR` is set or when stdout is not a TTY (pipes, CI). Same format is logged in plain text in those cases.
|
|
18
|
+
- README updated: no `npm install chalk`; colours described as built-in ANSI.
|
|
19
|
+
|
|
3
20
|
## 0.9.14
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -73,25 +73,21 @@ npm install syntropylog
|
|
|
73
73
|
|
|
74
74
|
By default, SyntropyLog outputs **lightweight plain JSON to the console — automatically, with no configuration needed**. No imports, no setup, no extra dependencies.
|
|
75
75
|
|
|
76
|
-
If you want **colored, human-readable output** for development, use one of the pretty console transports
|
|
76
|
+
If you want **colored, human-readable output** for development, use one of the pretty console transports. Colours use **built-in ANSI codes** (no chalk or extra dependency). When stdout is a TTY you get colours; when piping or in CI, or if `NO_COLOR` is set, the same format is shown in plain text.
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
| `ClassicConsoleTransport` | Structured single-line | ✅ Colored | Plain text | Development |
|
|
86
|
-
| `PrettyConsoleTransport` | Human-readable pretty | ✅ Colored | Plain text | Development / debugging |
|
|
87
|
-
| `CompactConsoleTransport` | Compact one-liner | ✅ Colored | Plain text | Development |
|
|
88
|
-
| `ColorfulConsoleTransport` | Full-line colored | ✅ Colored | Plain text | Development |
|
|
78
|
+
| Transport | Style | Recommended for |
|
|
79
|
+
| :--- | :--- | :--- |
|
|
80
|
+
| *(default)* | Plain JSON | Production / log aggregators |
|
|
81
|
+
| `ClassicConsoleTransport` | Structured single-line, colored | Development |
|
|
82
|
+
| `PrettyConsoleTransport` | Human-readable pretty, colored | Development / debugging |
|
|
83
|
+
| `CompactConsoleTransport` | Compact one-liner, colored | Development |
|
|
84
|
+
| `ColorfulConsoleTransport` | Full-line colored | Development |
|
|
89
85
|
|
|
90
86
|
```typescript
|
|
91
87
|
// Default — no import needed, works out of the box
|
|
92
88
|
syntropyLog.init({ logger: { level: 'info', serviceName: 'my-app' } });
|
|
93
89
|
|
|
94
|
-
// Pretty
|
|
90
|
+
// Pretty + colors (built-in ANSI; no extra deps)
|
|
95
91
|
import { ClassicConsoleTransport } from 'syntropylog';
|
|
96
92
|
|
|
97
93
|
syntropyLog.init({
|
package/dist/index.cjs
CHANGED
|
@@ -7,10 +7,8 @@ var node_async_hooks = require('node:async_hooks');
|
|
|
7
7
|
var crypto = require('crypto');
|
|
8
8
|
var util = require('node:util');
|
|
9
9
|
var flatted = require('flatted');
|
|
10
|
-
var module$1 = require('module');
|
|
11
10
|
var redis = require('redis');
|
|
12
11
|
|
|
13
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
14
12
|
function _interopNamespaceDefault(e) {
|
|
15
13
|
var n = Object.create(null);
|
|
16
14
|
if (e) {
|
|
@@ -2556,55 +2554,71 @@ const syntropyLog = SyntropyLog.getInstance();
|
|
|
2556
2554
|
|
|
2557
2555
|
/**
|
|
2558
2556
|
* @file src/logger/transports/optionalChalk.ts
|
|
2559
|
-
* @description
|
|
2560
|
-
*
|
|
2561
|
-
* fails to load, a no-op identity is used (no colors).
|
|
2557
|
+
* @description Built-in chalk-like API using ANSI escape codes. No chalk dependency.
|
|
2558
|
+
* Used by ClassicConsoleTransport, PrettyConsoleTransport, CompactConsoleTransport, ColorfulConsoleTransport.
|
|
2562
2559
|
*/
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
noColor.bgRed = noColor;
|
|
2569
|
-
noColor.yellow = noColor;
|
|
2570
|
-
noColor.cyan = noColor;
|
|
2571
|
-
noColor.green = noColor;
|
|
2572
|
-
noColor.gray = noColor;
|
|
2573
|
-
noColor.magenta = noColor;
|
|
2574
|
-
noColor.blue = noColor;
|
|
2575
|
-
noColor.bgWhite = noColor;
|
|
2576
|
-
noColor.dim = noColor;
|
|
2577
|
-
return noColor;
|
|
2560
|
+
const RESET = '\x1b[0m';
|
|
2561
|
+
function wrap(s, codes) {
|
|
2562
|
+
if (codes.length === 0)
|
|
2563
|
+
return s;
|
|
2564
|
+
return `\x1b[${codes.join(';')}m${s}${RESET}`;
|
|
2578
2565
|
}
|
|
2579
|
-
function
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
}
|
|
2596
|
-
|
|
2566
|
+
function createChain(codes) {
|
|
2567
|
+
const fn = ((s) => wrap(s, codes));
|
|
2568
|
+
const add = (code) => createChain([...codes, code]);
|
|
2569
|
+
// Lazy getters: only create the next chain when the property is accessed (avoids stack overflow)
|
|
2570
|
+
Object.defineProperty(fn, 'white', { get: () => add(37), enumerable: true });
|
|
2571
|
+
Object.defineProperty(fn, 'bold', { get: () => add(1), enumerable: true });
|
|
2572
|
+
Object.defineProperty(fn, 'red', { get: () => add(31), enumerable: true });
|
|
2573
|
+
Object.defineProperty(fn, 'bgRed', { get: () => add(41), enumerable: true });
|
|
2574
|
+
Object.defineProperty(fn, 'yellow', { get: () => add(33), enumerable: true });
|
|
2575
|
+
Object.defineProperty(fn, 'cyan', { get: () => add(36), enumerable: true });
|
|
2576
|
+
Object.defineProperty(fn, 'green', { get: () => add(32), enumerable: true });
|
|
2577
|
+
Object.defineProperty(fn, 'gray', { get: () => add(90), enumerable: true });
|
|
2578
|
+
Object.defineProperty(fn, 'magenta', {
|
|
2579
|
+
get: () => add(35),
|
|
2580
|
+
enumerable: true,
|
|
2581
|
+
});
|
|
2582
|
+
Object.defineProperty(fn, 'blue', { get: () => add(34), enumerable: true });
|
|
2583
|
+
Object.defineProperty(fn, 'bgWhite', {
|
|
2584
|
+
get: () => add(47),
|
|
2585
|
+
enumerable: true,
|
|
2586
|
+
});
|
|
2587
|
+
Object.defineProperty(fn, 'dim', { get: () => add(2), enumerable: true });
|
|
2588
|
+
return fn;
|
|
2597
2589
|
}
|
|
2598
2590
|
let cached = null;
|
|
2599
2591
|
/**
|
|
2600
|
-
* Returns a chalk-like instance
|
|
2601
|
-
*
|
|
2592
|
+
* Returns a chalk-like instance using built-in ANSI colors. No external chalk dependency.
|
|
2593
|
+
* Respects NO_COLOR and disables colors when stdout is not a TTY (e.g. pipes, CI).
|
|
2602
2594
|
*/
|
|
2603
2595
|
function getOptionalChalk() {
|
|
2604
2596
|
if (cached !== null) {
|
|
2605
2597
|
return cached;
|
|
2606
2598
|
}
|
|
2607
|
-
|
|
2599
|
+
const noColor = process.env.NO_COLOR !== undefined &&
|
|
2600
|
+
process.env.NO_COLOR !== '' &&
|
|
2601
|
+
process.env.NO_COLOR !== '0';
|
|
2602
|
+
const isTTY = typeof process.stdout?.isTTY === 'boolean' && process.stdout.isTTY;
|
|
2603
|
+
if (noColor || !isTTY) {
|
|
2604
|
+
const identity = ((s) => s);
|
|
2605
|
+
identity.white = identity;
|
|
2606
|
+
identity.bold = identity;
|
|
2607
|
+
identity.red = identity;
|
|
2608
|
+
identity.bgRed = identity;
|
|
2609
|
+
identity.yellow = identity;
|
|
2610
|
+
identity.cyan = identity;
|
|
2611
|
+
identity.green = identity;
|
|
2612
|
+
identity.gray = identity;
|
|
2613
|
+
identity.magenta = identity;
|
|
2614
|
+
identity.blue = identity;
|
|
2615
|
+
identity.bgWhite = identity;
|
|
2616
|
+
identity.dim = identity;
|
|
2617
|
+
cached = identity;
|
|
2618
|
+
}
|
|
2619
|
+
else {
|
|
2620
|
+
cached = createChain([]);
|
|
2621
|
+
}
|
|
2608
2622
|
return cached;
|
|
2609
2623
|
}
|
|
2610
2624
|
|