syntropylog 0.9.13 → 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 +17 -0
- package/CONTRIBUTING.md +14 -6
- package/README.md +9 -12
- package/dist/index.cjs +63 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +24 -2
- package/dist/index.mjs +63 -6
- package/dist/index.mjs.map +1 -1
- package/dist/logger/transports/BaseConsolePrettyTransport.js +2 -7
- package/dist/logger/transports/BaseConsolePrettyTransport.js.map +1 -1
- package/dist/logger/transports/ColorfulConsoleTransport.js.map +1 -1
- package/dist/logger/transports/CompactConsoleTransport.js +1 -1
- package/dist/logger/transports/CompactConsoleTransport.js.map +1 -1
- package/dist/logger/transports/PrettyConsoleTransport.js.map +1 -1
- package/dist/logger/transports/optionalChalk.js +63 -0
- package/dist/logger/transports/optionalChalk.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/logger/transports/BaseConsolePrettyTransport.d.ts +3 -2
- package/dist/types/logger/transports/ColorfulConsoleTransport.d.ts +3 -3
- package/dist/types/logger/transports/PrettyConsoleTransport.d.ts +3 -3
- package/dist/types/logger/transports/optionalChalk.d.ts +26 -0
- package/package.json +1 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
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
|
+
|
|
12
|
+
## 0.9.14
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- **Chalk optional for pretty console transports (Classic, Pretty, Compact, Colorful)**
|
|
17
|
+
- **Fix**: `ClassicConsoleTransport` (and other chalk-powered transports) now work in both ESM (tsx + `"type": "module"`) and CJS (e.g. ts-node) consumers. Chalk is loaded optionally via a small helper that uses `require` in CJS and `createRequire(import.meta.url)` in ESM; if chalk is missing or fails to load, a no-op is used so the same format is logged without colors.
|
|
18
|
+
- **README**: Clarified that chalk is optional — install it for colors, or use the same transports without it for plain-text output. Table updated to show "With chalk" / "Without chalk" and added ColorfulConsoleTransport.
|
|
19
|
+
|
|
3
20
|
## 0.9.13
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/CONTRIBUTING.md
CHANGED
|
@@ -88,13 +88,21 @@ We welcome code contributions! To contribute code, please follow these steps:
|
|
|
88
88
|
|
|
89
89
|
## Release process (maintainers)
|
|
90
90
|
|
|
91
|
-
Releases use [Changesets](https://github.com/changesets/changesets) and GitHub Actions
|
|
91
|
+
Releases use [Changesets](https://github.com/changesets/changesets) and GitHub Actions. **Para que la versión suba en npm, siempre tienes que hacer una de estas dos cosas:**
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
3. **
|
|
93
|
+
### Opción A: Usar el PR que crea el action
|
|
94
|
+
|
|
95
|
+
1. **Añade un changeset** al cambiar la librería: `pnpm changeset` (elige tipo de versión y describe el cambio).
|
|
96
|
+
2. **Push a `main`**. El workflow crea un PR **"Version Packages"** con el bump (ej. 0.9.12 → 0.9.13) y el CHANGELOG actualizado. **Todavía no publica en npm.**
|
|
97
|
+
3. **Mergea ese PR** en `main`. Ese merge vuelve a disparar el workflow y **ahí sí** se ejecuta `publish` y la nueva versión aparece en npm.
|
|
98
|
+
|
|
99
|
+
### Opción B: Subir la versión a mano (sin PR)
|
|
100
|
+
|
|
101
|
+
1. Con changesets ya en el repo, en local: `pnpm run version-packages`. Eso actualiza `package.json`, CHANGELOG y borra los changesets.
|
|
102
|
+
2. **Commit** (package.json, CHANGELOG.md, y los .changeset/*.md borrados) y **push a `main`**.
|
|
103
|
+
3. El workflow corre, no hay changesets que aplicar, y ejecuta **publish** → la versión sube a npm.
|
|
104
|
+
|
|
105
|
+
En ambos casos, **main** y **npm** quedan con la misma versión.
|
|
98
106
|
|
|
99
107
|
## Getting Help
|
|
100
108
|
|
package/README.md
CHANGED
|
@@ -73,24 +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
|
|
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 + colored | ✅ | Development |
|
|
86
|
-
| `PrettyConsoleTransport` | Human-readable pretty print | ✅ | Development / debugging |
|
|
87
|
-
| `CompactConsoleTransport` | Compact one-liner | ✅ | 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 |
|
|
88
85
|
|
|
89
86
|
```typescript
|
|
90
87
|
// Default — no import needed, works out of the box
|
|
91
88
|
syntropyLog.init({ logger: { level: 'info', serviceName: 'my-app' } });
|
|
92
89
|
|
|
93
|
-
//
|
|
90
|
+
// Pretty + colors (built-in ANSI; no extra deps)
|
|
94
91
|
import { ClassicConsoleTransport } from 'syntropylog';
|
|
95
92
|
|
|
96
93
|
syntropyLog.init({
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,6 @@ 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 chalk = require('chalk');
|
|
11
10
|
var redis = require('redis');
|
|
12
11
|
|
|
13
12
|
function _interopNamespaceDefault(e) {
|
|
@@ -2554,9 +2553,68 @@ class SyntropyLog extends events.EventEmitter {
|
|
|
2554
2553
|
const syntropyLog = SyntropyLog.getInstance();
|
|
2555
2554
|
|
|
2556
2555
|
/**
|
|
2557
|
-
* @file src/logger/transports/
|
|
2558
|
-
* @description
|
|
2556
|
+
* @file src/logger/transports/optionalChalk.ts
|
|
2557
|
+
* @description Built-in chalk-like API using ANSI escape codes. No chalk dependency.
|
|
2558
|
+
* Used by ClassicConsoleTransport, PrettyConsoleTransport, CompactConsoleTransport, ColorfulConsoleTransport.
|
|
2559
2559
|
*/
|
|
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}`;
|
|
2565
|
+
}
|
|
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;
|
|
2582
|
+
}
|
|
2583
|
+
let cached = null;
|
|
2584
|
+
/**
|
|
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).
|
|
2587
|
+
*/
|
|
2588
|
+
function getOptionalChalk() {
|
|
2589
|
+
if (cached !== null) {
|
|
2590
|
+
return cached;
|
|
2591
|
+
}
|
|
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
|
+
}
|
|
2615
|
+
return cached;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2560
2618
|
/**
|
|
2561
2619
|
* @class BaseConsolePrettyTransport
|
|
2562
2620
|
* @description Provides common functionality for "pretty" console transports,
|
|
@@ -2567,8 +2625,7 @@ const syntropyLog = SyntropyLog.getInstance();
|
|
|
2567
2625
|
class BaseConsolePrettyTransport extends Transport {
|
|
2568
2626
|
constructor(options) {
|
|
2569
2627
|
super(options);
|
|
2570
|
-
|
|
2571
|
-
this.chalk = chalk;
|
|
2628
|
+
this.chalk = getOptionalChalk();
|
|
2572
2629
|
}
|
|
2573
2630
|
/**
|
|
2574
2631
|
* The core log method. It handles common logic and delegates specific
|
|
@@ -2706,7 +2763,7 @@ class CompactConsoleTransport extends BaseConsolePrettyTransport {
|
|
|
2706
2763
|
// Simple stringify for objects/arrays in metadata.
|
|
2707
2764
|
const formattedValue = typeof value === 'object' && value !== null
|
|
2708
2765
|
? JSON.stringify(value)
|
|
2709
|
-
: value;
|
|
2766
|
+
: String(value);
|
|
2710
2767
|
return `${this.chalk.dim(key)}=${this.chalk.gray(formattedValue)}`;
|
|
2711
2768
|
})
|
|
2712
2769
|
.join(' ');
|