syntropylog 0.9.14 → 0.9.15
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 +9 -0
- package/README.md +9 -13
- package/dist/index.cjs +48 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.mjs +48 -40
- package/dist/index.mjs.map +1 -1
- package/dist/logger/transports/optionalChalk.js +48 -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,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Built-in ANSI colors: remove chalk dependency**
|
|
8
|
+
- Pretty console transports (Classic, Pretty, Compact, Colorful) now use a built-in chalk-like API implemented with ANSI escape codes. No chalk peer dependency.
|
|
9
|
+
- 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.
|
|
10
|
+
- README updated: no `npm install chalk`; colours described as built-in ANSI.
|
|
11
|
+
|
|
3
12
|
## 0.9.14
|
|
4
13
|
|
|
5
14
|
### 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,64 @@ 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
|
-
return createNoColorChalk();
|
|
2566
|
+
function createChain(codes) {
|
|
2567
|
+
const fn = ((s) => wrap(s, codes));
|
|
2568
|
+
const add = (code) => createChain([...codes, code]);
|
|
2569
|
+
fn.white = add(37);
|
|
2570
|
+
fn.bold = add(1);
|
|
2571
|
+
fn.red = add(31);
|
|
2572
|
+
fn.bgRed = add(41);
|
|
2573
|
+
fn.yellow = add(33);
|
|
2574
|
+
fn.cyan = add(36);
|
|
2575
|
+
fn.green = add(32);
|
|
2576
|
+
fn.gray = add(90);
|
|
2577
|
+
fn.magenta = add(35);
|
|
2578
|
+
fn.blue = add(34);
|
|
2579
|
+
fn.bgWhite = add(47);
|
|
2580
|
+
fn.dim = add(2);
|
|
2581
|
+
return fn;
|
|
2597
2582
|
}
|
|
2598
2583
|
let cached = null;
|
|
2599
2584
|
/**
|
|
2600
|
-
* Returns a chalk-like instance
|
|
2601
|
-
*
|
|
2585
|
+
* Returns a chalk-like instance using built-in ANSI colors. No external chalk dependency.
|
|
2586
|
+
* Respects NO_COLOR and disables colors when stdout is not a TTY (e.g. pipes, CI).
|
|
2602
2587
|
*/
|
|
2603
2588
|
function getOptionalChalk() {
|
|
2604
2589
|
if (cached !== null) {
|
|
2605
2590
|
return cached;
|
|
2606
2591
|
}
|
|
2607
|
-
|
|
2592
|
+
const noColor = process.env.NO_COLOR !== undefined &&
|
|
2593
|
+
process.env.NO_COLOR !== '' &&
|
|
2594
|
+
process.env.NO_COLOR !== '0';
|
|
2595
|
+
const isTTY = typeof process.stdout?.isTTY === 'boolean' && process.stdout.isTTY;
|
|
2596
|
+
if (noColor || !isTTY) {
|
|
2597
|
+
const identity = ((s) => s);
|
|
2598
|
+
identity.white = identity;
|
|
2599
|
+
identity.bold = identity;
|
|
2600
|
+
identity.red = identity;
|
|
2601
|
+
identity.bgRed = identity;
|
|
2602
|
+
identity.yellow = identity;
|
|
2603
|
+
identity.cyan = identity;
|
|
2604
|
+
identity.green = identity;
|
|
2605
|
+
identity.gray = identity;
|
|
2606
|
+
identity.magenta = identity;
|
|
2607
|
+
identity.blue = identity;
|
|
2608
|
+
identity.bgWhite = identity;
|
|
2609
|
+
identity.dim = identity;
|
|
2610
|
+
cached = identity;
|
|
2611
|
+
}
|
|
2612
|
+
else {
|
|
2613
|
+
cached = createChain([]);
|
|
2614
|
+
}
|
|
2608
2615
|
return cached;
|
|
2609
2616
|
}
|
|
2610
2617
|
|