@pondoknusa/log 5.1.0 → 6.0.1
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 +70 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @pondoknusa/log
|
|
2
|
+
|
|
3
|
+
Structured logging channels — stdout, file, and stack — behind a `LogRepository` facade.
|
|
4
|
+
|
|
5
|
+
Application code should emit structured logs without caring where they are written, so this
|
|
6
|
+
package separates the `Log` call from the channel that records it. A `LogManager` builds channels
|
|
7
|
+
from `config/log.ts`, `LogRepository` forwards leveled calls to the configured channel, and a
|
|
8
|
+
`stack` channel fans one entry out to several destinations at once.
|
|
9
|
+
|
|
10
|
+
Each entry is serialized as a single JSON line with a level, timestamp, and context, and sensitive
|
|
11
|
+
context keys are redacted before they are written. Its only dependency is `@pondoknusa/support`
|
|
12
|
+
(for that redaction), so there is no logging framework underneath.
|
|
13
|
+
|
|
14
|
+
> Part of the [Pondoknusa](https://pondoknusa.dev) framework — a TypeScript-native full-stack
|
|
15
|
+
> framework built on standard Web APIs. Requires **Node.js ≥ 26**.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @pondoknusa/log
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { LogManager, LogRepository } from '@pondoknusa/log';
|
|
27
|
+
|
|
28
|
+
const manager = new LogManager({
|
|
29
|
+
default: 'stack',
|
|
30
|
+
channels: {
|
|
31
|
+
stdout: { channel: 'stdout' },
|
|
32
|
+
file: { channel: 'file', path: 'storage/logs/pondoknusa.log' },
|
|
33
|
+
stack: { channel: 'stack', channels: ['stdout', 'file'] },
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const log = new LogRepository(manager);
|
|
38
|
+
|
|
39
|
+
log.info('order.placed', { orderId: order.id, userId: user.id });
|
|
40
|
+
log.error('payment.failed', { code: 'card_declined' });
|
|
41
|
+
|
|
42
|
+
// Target a single channel directly, bypassing the default
|
|
43
|
+
manager.channel('file').warn('cache.miss', { key: 'dashboard' });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The four levels are `debug`, `info`, `warn`, and `error`, and `stack` channels may nest other
|
|
47
|
+
named channels. In an application, `LogServiceProvider` builds the repository from `config/log.ts`
|
|
48
|
+
(`LOG_CHANNEL` selects `stdout`, `file`, or `stack`) and you emit through the `Log` facade from
|
|
49
|
+
`@pondoknusa/core`:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { Log } from '@pondoknusa/core';
|
|
53
|
+
|
|
54
|
+
Log.info('order.placed', { orderId: order.id, userId: user.id });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Related packages
|
|
58
|
+
|
|
59
|
+
- [`@pondoknusa/support`](https://www.npmjs.com/package/@pondoknusa/support) — provides
|
|
60
|
+
`redactSensitive()`, used to strip secrets from log context.
|
|
61
|
+
- [`@pondoknusa/core`](https://www.npmjs.com/package/@pondoknusa/core) — `LogServiceProvider`
|
|
62
|
+
wires the channel from `config/log.ts` and exposes the `Log` facade.
|
|
63
|
+
|
|
64
|
+
## Documentation
|
|
65
|
+
|
|
66
|
+
- [Observability guide](https://pondoknusa.dev/cookbook/observability)
|
|
67
|
+
- [Package reference](https://pondoknusa.dev/reference/generated/packages/log)
|
|
68
|
+
- [Source](https://git.simonharms.com/thesimonharms/pondoknusa/src/branch/main/packages/log)
|
|
69
|
+
|
|
70
|
+
MIT © Pondoknusa Contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pondoknusa/log",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@pondoknusa/support": "
|
|
18
|
+
"@pondoknusa/support": "6.0.1"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist"
|