@ontrails/logtape 0.2.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/CHANGELOG.md +62 -0
- package/README.md +38 -0
- package/package.json +41 -0
- package/src/index.ts +59 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`664e8bb`](https://github.com/outfitter-dev/trails/commit/664e8bb049e61f1d47cec1dd246606707af5d1a8): Point public installation examples at exact approved 0.2.0 versions and distinguish the prepared source release from pending npm publication.
|
|
8
|
+
- [`b3ddf91`](https://github.com/outfitter-dev/trails/commit/b3ddf918ada8211f44983512e2bbdfbc5b66d722): Prepare the first normal Trails release at `0.2.0` on `latest`, replacing the unpublished 1.0.0 source release. The target advances the original `0.1.0` source minor, which was never published under the current package names. Public packages remain in lockstep. Update consumer installation guidance and provide a temporary manifest bridge for old 1.0 beta sources. Published beta versions remain unchanged; minor 0.x releases may carry documented breaking changes.
|
|
9
|
+
|
|
10
|
+
The `1.0.0` section retained below records an unpublished preparation, not an npm release. Its accumulated changes are included in `0.2.0`; the section remains as source history alongside the published beta entries.
|
|
11
|
+
|
|
12
|
+
## 1.0.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [`50e2779`](https://github.com/outfitter-dev/trails/commit/50e27796d074851bccd57d7df009db749757b457): Extract the real `@ontrails/logtape` and `@ontrails/pino` adapters from the
|
|
17
|
+
temporary observability subpaths. The new packages own their namesake foreign
|
|
18
|
+
dependencies and preserve Trails record metadata, levels, redaction boundaries,
|
|
19
|
+
and lifecycle behavior; the old subpaths are removed in the pre-v1 hard cut.
|
|
20
|
+
|
|
21
|
+
Add governed Regrade transitions for both exact import replacements and expose
|
|
22
|
+
the observability adapter target through the shared adapter readiness check.
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- [`b1fbe57`](https://github.com/outfitter-dev/trails/commit/b1fbe574e6f44d1fecb5e3a000270955c0a77b7b): Publish Bun-validated package tarballs through an npm trusted-publishing adapter
|
|
27
|
+
binding, add exact repository metadata for each public workspace package, and
|
|
28
|
+
correct the native Bun release descriptor to its pack-only runtime boundary.
|
|
29
|
+
|
|
30
|
+
## 1.0.0-beta.50
|
|
31
|
+
|
|
32
|
+
## 1.0.0-beta.49
|
|
33
|
+
|
|
34
|
+
## 1.0.0-beta.48
|
|
35
|
+
|
|
36
|
+
## 1.0.0-beta.47
|
|
37
|
+
|
|
38
|
+
## 1.0.0-beta.46
|
|
39
|
+
|
|
40
|
+
## 1.0.0-beta.45
|
|
41
|
+
|
|
42
|
+
## 1.0.0-beta.44
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- [`b1fbe57`](https://github.com/outfitter-dev/trails/commit/b1fbe574e6f44d1fecb5e3a000270955c0a77b7b): Publish Bun-validated package tarballs through an npm trusted-publishing adapter
|
|
47
|
+
binding, add exact repository metadata for each public workspace package, and
|
|
48
|
+
correct the native Bun release descriptor to its pack-only runtime boundary.
|
|
49
|
+
|
|
50
|
+
## 1.0.0-beta.43
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- [`50e2779`](https://github.com/outfitter-dev/trails/commit/50e27796d074851bccd57d7df009db749757b457): Extract the real `@ontrails/logtape` and `@ontrails/pino` adapters from the
|
|
55
|
+
temporary observability subpaths. The new packages own their namesake foreign
|
|
56
|
+
dependencies and preserve Trails record metadata, levels, redaction boundaries,
|
|
57
|
+
and lifecycle behavior; the old subpaths are removed in the pre-v1 hard cut.
|
|
58
|
+
|
|
59
|
+
Add governed Regrade transitions for both exact import replacements and expose
|
|
60
|
+
the observability adapter target through the shared adapter readiness check.
|
|
61
|
+
|
|
62
|
+
All notable changes to this package are documented through the Trails release process.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @ontrails/logtape
|
|
2
|
+
|
|
3
|
+
Real LogTape adapter for Trails observability. This extracted package owns the LogTape dependency boundary, keeping `@ontrails/observability` independent of foreign logging libraries.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { configure, getConsoleSink } from '@logtape/logtape';
|
|
9
|
+
import { createLogtapeSink } from '@ontrails/logtape';
|
|
10
|
+
|
|
11
|
+
await configure({
|
|
12
|
+
loggers: [{ category: 'app', lowestLevel: 'info', sinks: ['console'] }],
|
|
13
|
+
sinks: { console: getConsoleSink() },
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const sink = createLogtapeSink();
|
|
17
|
+
sink.write({
|
|
18
|
+
category: 'app.http',
|
|
19
|
+
level: 'info',
|
|
20
|
+
message: 'request received',
|
|
21
|
+
metadata: { requestId: 'req_123' },
|
|
22
|
+
timestamp: new Date(),
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The application owns `configure()`; this library only resolves or accepts a configured LogTape logger. It forwards Trails records through LogTape's native `emit()` integration path, preserving the record timestamp, category, structured metadata, and the `warn` to `warning` level translation. Trails redaction occurs before the record reaches this adapter, and `silent` records do not reach LogTape.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
These commands target stable `0.2.0`. Run them after that version is published to npm.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
bun add --exact @ontrails/observability@0.2.0 @ontrails/logtape@0.2.0
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Migration
|
|
37
|
+
|
|
38
|
+
This package is the final LogTape adapter in the pre-v1 hard cut. No compatibility subpath remains; see the logging migration guide for the explicit historical import map.
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ontrails/logtape",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/outfitter-dev/trails.git",
|
|
7
|
+
"directory": "adapters/logtape"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src/**/*.ts",
|
|
11
|
+
"!src/**/__tests__/**",
|
|
12
|
+
"!src/**/*.test.ts",
|
|
13
|
+
"!src/**/*.test-d.ts",
|
|
14
|
+
"README.md",
|
|
15
|
+
"CHANGELOG.md"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./src/index.ts",
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -b",
|
|
24
|
+
"test": "bun test",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"lint": "oxlint ./src",
|
|
27
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@logtape/logtape": "^2.2.4"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@ontrails/observability": "^0.2.0",
|
|
34
|
+
"zod": "^4.3.5"
|
|
35
|
+
},
|
|
36
|
+
"trails": {
|
|
37
|
+
"adapter": {
|
|
38
|
+
"target": "observability"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getLogger } from '@logtape/logtape';
|
|
2
|
+
import type { Logger } from '@logtape/logtape';
|
|
3
|
+
|
|
4
|
+
import type { LogLevel, LogRecord, LogSink } from '@ontrails/observability';
|
|
5
|
+
|
|
6
|
+
export interface LogtapeSinkOptions {
|
|
7
|
+
/** Existing configured LogTape logger. The application owns LogTape setup. */
|
|
8
|
+
readonly logger?: Logger | undefined;
|
|
9
|
+
/** Sink name exposed to Trails observe configuration. Defaults to `logtape`. */
|
|
10
|
+
readonly name?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type ForwardMethod = 'trace' | 'debug' | 'info' | 'warning' | 'error' | 'fatal';
|
|
14
|
+
|
|
15
|
+
const LEVEL_MAP: Record<LogLevel, ForwardMethod | undefined> = {
|
|
16
|
+
debug: 'debug',
|
|
17
|
+
error: 'error',
|
|
18
|
+
fatal: 'fatal',
|
|
19
|
+
info: 'info',
|
|
20
|
+
silent: undefined,
|
|
21
|
+
trace: 'trace',
|
|
22
|
+
warn: 'warning',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const buildProperties = (record: LogRecord): Record<string, unknown> => ({
|
|
26
|
+
...record.metadata,
|
|
27
|
+
category: record.category,
|
|
28
|
+
timestamp: record.timestamp.toISOString(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a Trails sink backed by LogTape. The adapter deliberately never calls
|
|
33
|
+
* `configure()`: libraries read the application-owned logger configuration.
|
|
34
|
+
*/
|
|
35
|
+
export const createLogtapeSink = (
|
|
36
|
+
options: LogtapeSinkOptions = {}
|
|
37
|
+
): LogSink => {
|
|
38
|
+
const configuredLogger = options.logger;
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
name: options.name ?? 'logtape',
|
|
42
|
+
write(record: LogRecord): void {
|
|
43
|
+
const method = LEVEL_MAP[record.level];
|
|
44
|
+
if (method === undefined) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const logger =
|
|
48
|
+
configuredLogger ??
|
|
49
|
+
getLogger(record.category.split('.').filter(Boolean));
|
|
50
|
+
logger.emit({
|
|
51
|
+
level: method,
|
|
52
|
+
message: [record.message],
|
|
53
|
+
properties: buildProperties(record),
|
|
54
|
+
rawMessage: record.message,
|
|
55
|
+
timestamp: record.timestamp.getTime(),
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
};
|