@mugenlabs/logtape-devtools 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/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.mjs +1234 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Yago Gonzalez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @mugenlabs/logtape-devtools
|
|
2
|
+
|
|
3
|
+
A [TanStack DevTools](https://tanstack.com/devtools) plugin for inspecting [LogTape](https://logtape.org) logs in the browser.
|
|
4
|
+
|
|
5
|
+
Filter, search, and inspect structured logs in real time — without leaving the browser DevTools overlay.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Live log streaming** — see logs as they happen
|
|
10
|
+
- **Level filtering** — toggle trace, debug, info, warning, error, fatal
|
|
11
|
+
- **Category search** — filter by logger category
|
|
12
|
+
- **Structured inspection** — expand logs to view properties and stack traces
|
|
13
|
+
- **Pause & resume** — freeze the log stream to inspect entries
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mugenlabs/logtape-devtools @logtape/logtape @tanstack/react-devtools
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### 1. Configure the LogTape sink
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { configure } from "@logtape/logtape";
|
|
27
|
+
import { createDevtoolsSink } from "@mugenlabs/logtape-devtools";
|
|
28
|
+
|
|
29
|
+
await configure({
|
|
30
|
+
sinks: { devtools: createDevtoolsSink() },
|
|
31
|
+
loggers: [{ category: ["app"], sinks: ["devtools"], lowestLevel: "debug" }],
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Add the DevTools plugin
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { TanStackDevtools } from "@tanstack/react-devtools";
|
|
39
|
+
import { createLogTapeDevtoolsPlugin } from "@mugenlabs/logtape-devtools";
|
|
40
|
+
|
|
41
|
+
const logtapePlugin = createLogTapeDevtoolsPlugin();
|
|
42
|
+
|
|
43
|
+
function App() {
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
{/* your app */}
|
|
47
|
+
<TanStackDevtools plugins={[logtapePlugin]} />
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
### `createDevtoolsSink(options?)`
|
|
56
|
+
|
|
57
|
+
Creates a LogTape sink that forwards log records to the devtools store.
|
|
58
|
+
|
|
59
|
+
| Option | Type | Default | Description |
|
|
60
|
+
| --- | --- | --- | --- |
|
|
61
|
+
| `store` | `LogStore` | `defaultLogStore` | Custom log store instance |
|
|
62
|
+
| `captureStackTrace` | `boolean` | `true` (dev only) | Capture stack traces |
|
|
63
|
+
| `stackTraceDepth` | `number` | `20` | Max stack trace frames |
|
|
64
|
+
|
|
65
|
+
### `createLogTapeDevtoolsPlugin(options?)`
|
|
66
|
+
|
|
67
|
+
Creates the TanStack DevTools plugin component.
|
|
68
|
+
|
|
69
|
+
| Option | Type | Default | Description |
|
|
70
|
+
| --- | --- | --- | --- |
|
|
71
|
+
| `store` | `LogStore` | `defaultLogStore` | Custom log store instance |
|
|
72
|
+
|
|
73
|
+
### `createLogStore(options?)`
|
|
74
|
+
|
|
75
|
+
Creates a standalone log store for advanced use cases.
|
|
76
|
+
|
|
77
|
+
| Option | Type | Default | Description |
|
|
78
|
+
| --- | --- | --- | --- |
|
|
79
|
+
| `maxRecords` | `number` | `1000` | Maximum records to retain |
|
|
80
|
+
|
|
81
|
+
## Demo
|
|
82
|
+
|
|
83
|
+
See the live demo and full documentation at [logtape-devtools.mugenlabs.dev](https://logtape-devtools.mugenlabs.dev/).
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Sink } from '@logtape/logtape';
|
|
3
|
+
|
|
4
|
+
type LogLevel = "trace" | "debug" | "info" | "warning" | "error" | "fatal";
|
|
5
|
+
declare const LOG_LEVELS: LogLevel[];
|
|
6
|
+
interface DevtoolsLogRecord {
|
|
7
|
+
/** Source location of the log call (only present when `experimentalCaptureStackTrace` is enabled). */
|
|
8
|
+
caller?: string;
|
|
9
|
+
category: string[];
|
|
10
|
+
id: string;
|
|
11
|
+
level: LogLevel;
|
|
12
|
+
message: unknown[];
|
|
13
|
+
messageText: string;
|
|
14
|
+
properties: Record<string, unknown>;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type Listener = () => void;
|
|
19
|
+
interface LogStore {
|
|
20
|
+
addRecord(record: DevtoolsLogRecord): void;
|
|
21
|
+
clear(): void;
|
|
22
|
+
getSnapshot(): DevtoolsLogRecord[];
|
|
23
|
+
setMaxSize(size: number): void;
|
|
24
|
+
subscribe(listener: Listener): () => void;
|
|
25
|
+
}
|
|
26
|
+
declare function createLogStore(maxSize?: number): LogStore;
|
|
27
|
+
/** Default shared store instance used when no custom store is provided */
|
|
28
|
+
declare const defaultLogStore: LogStore;
|
|
29
|
+
|
|
30
|
+
interface LogTapeDevtoolsPluginOptions {
|
|
31
|
+
/** Whether to open the devtools panel by default. Default: true */
|
|
32
|
+
defaultOpen?: boolean;
|
|
33
|
+
/** Plugin display name. Default: "LogTape" */
|
|
34
|
+
name?: string;
|
|
35
|
+
/** Custom log store instance. Must match the store passed to createDevtoolsSink. */
|
|
36
|
+
store?: LogStore;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a TanStack DevTools plugin config object for LogTape.
|
|
40
|
+
*
|
|
41
|
+
* Usage:
|
|
42
|
+
* ```tsx
|
|
43
|
+
* import { TanStackDevtools } from "@tanstack/react-devtools";
|
|
44
|
+
* import { createLogTapeDevtoolsPlugin } from "@mugenlabs/logtape-devtools";
|
|
45
|
+
*
|
|
46
|
+
* <TanStackDevtools plugins={[createLogTapeDevtoolsPlugin()]} />
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare const createLogTapeDevtoolsPlugin: (options?: LogTapeDevtoolsPluginOptions) => {
|
|
50
|
+
defaultOpen: boolean;
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
render: react_jsx_runtime.JSX.Element;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
interface Props {
|
|
57
|
+
store: LogStore;
|
|
58
|
+
}
|
|
59
|
+
declare const LogTapeDevtoolsPlugin: ({ store }: Props) => react_jsx_runtime.JSX.Element;
|
|
60
|
+
|
|
61
|
+
interface DevtoolsSinkOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Capture the source location of each log call via stack trace parsing.
|
|
64
|
+
*
|
|
65
|
+
* **Experimental / dev-only** — relies on `new Error().stack` which is
|
|
66
|
+
* engine-dependent. Automatically disabled in production builds (when
|
|
67
|
+
* `process.env.NODE_ENV === "production"`) because minified bundles
|
|
68
|
+
* produce meaningless file/line references. Note that source maps do not
|
|
69
|
+
* help here — browsers do not apply source maps to `Error.stack`.
|
|
70
|
+
*
|
|
71
|
+
* Set `forceStackTrace` to `true` to override the production guard — useful
|
|
72
|
+
* when your production build ships unminified code.
|
|
73
|
+
*
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
experimentalCaptureStackTrace?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Force stack trace capture even in production builds.
|
|
79
|
+
* Only has an effect when `experimentalCaptureStackTrace` is `true`.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
forceStackTrace?: boolean;
|
|
84
|
+
/** Custom log store instance. Defaults to the shared store. */
|
|
85
|
+
store?: LogStore;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Creates a LogTape sink that forwards log records to the devtools panel.
|
|
89
|
+
*
|
|
90
|
+
* Usage:
|
|
91
|
+
* ```ts
|
|
92
|
+
* import { configure } from "@logtape/logtape";
|
|
93
|
+
* import { createDevtoolsSink } from "@mugenlabs/logtape-devtools";
|
|
94
|
+
*
|
|
95
|
+
* await configure({
|
|
96
|
+
* sinks: { devtools: createDevtoolsSink() },
|
|
97
|
+
* loggers: [
|
|
98
|
+
* { category: ["app"], lowestLevel: "debug", sinks: ["devtools"] },
|
|
99
|
+
* ],
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare function createDevtoolsSink(options?: DevtoolsSinkOptions): Sink;
|
|
104
|
+
|
|
105
|
+
export { type DevtoolsLogRecord, type DevtoolsSinkOptions, LOG_LEVELS, type LogLevel, type LogStore, LogTapeDevtoolsPlugin, type LogTapeDevtoolsPluginOptions, createDevtoolsSink, createLogStore, createLogTapeDevtoolsPlugin, defaultLogStore };
|