drone logger prep work
This commit is contained in:
parent
eb37a22771
commit
632caf11ed
32
docs/drone-logger.md
Normal file
32
docs/drone-logger.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Gadget Code: GadgetLogTransportSocket
|
||||||
|
|
||||||
|
We recently finished a large refactor of GadgetLog into the @gadget/api package, and all components are now consumers of this one unified logging interface. [GadgetLog](../packages/api/src/lib/log.ts) makes use of [GadgetLogTransport](../packages/api/src/lib/log-transport.ts) to provide an abstract log transport. The logging system is working as intended. Console logging works as expected. File logging works as expected.
|
||||||
|
|
||||||
|
We are now going to implement `GadgetLogTransportSocket`, which will transmit a Socket.IO message `log` from `gadget-drone` to `gadget-code:backend`, which will forward the log message directly to [ChatSessionView](../gadget-code/frontend/src/pages/ChatSessionView.tsx) for display in [LogPanel](../gadget-code/frontend/src/components/LogPanel.tsx).
|
||||||
|
|
||||||
|
I have already added the `LogMessage` type to the drone message definitions, and added definitions to the appropriate interfaces we use for extending Socket.IO. It is a fire-n-forget message (no callback, no blocking).
|
||||||
|
|
||||||
|
## How It Works
|
||||||
|
|
||||||
|
You will simply pass the parameters passed to the GadgetLog API as a message over Socket.IO to the Log panel dislay in the IDE.
|
||||||
|
|
||||||
|
## Instructions
|
||||||
|
|
||||||
|
In this session, you will:
|
||||||
|
|
||||||
|
1. Implement [GadgetLogTransportSocket](../packages/api/src/lib/log-transport-socket.ts)
|
||||||
|
2. Register it for use as a default transport on the gadget-drone logger instance
|
||||||
|
3. Implement session message routing in gadget-code:backend to forward the message to gadget-code:frontend (the IDE)
|
||||||
|
4. Deliver log messages to the Chat Session view's Log panel for display
|
||||||
|
|
||||||
|
Log messages should render as closely to the Console Transport's output as possible, matching the colors used, and style.
|
||||||
|
|
||||||
|
When you are done, you will re-write this document in the style
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
Always search first in the project's `docs` directories for information and knowledge. Here are some starting points for this session:
|
||||||
|
|
||||||
|
- [UI Design and Style Guide](../gadget-code/docs/ui-design-guide.md)]
|
||||||
|
- [System Architecture](./architecture.md)
|
||||||
|
- [Socket Protocol](./socket-protocol.md)
|
||||||
@ -2,10 +2,12 @@
|
|||||||
// Copyright (C) 2026 Rob Colbert <rob.colbert@openplatform.us>
|
// Copyright (C) 2026 Rob Colbert <rob.colbert@openplatform.us>
|
||||||
// Licensed under the Apache License, Version 2.0
|
// Licensed under the Apache License, Version 2.0
|
||||||
|
|
||||||
import { IChatSession } from "../interfaces/chat-session.ts";
|
|
||||||
import { IChatTurn } from "../interfaces/chat-turn.ts";
|
import { IChatTurn } from "../interfaces/chat-turn.ts";
|
||||||
import { IDroneRegistration } from "../interfaces/drone-registration.ts";
|
import { IDroneRegistration } from "../interfaces/drone-registration.ts";
|
||||||
import { IProject } from "../interfaces/project.ts";
|
|
||||||
|
import { GadgetComponent } from "../lib/component.ts";
|
||||||
|
import { GadgetLogLevel } from "../lib/log.ts";
|
||||||
|
|
||||||
import { WorkspaceMode } from "./ide.ts";
|
import { WorkspaceMode } from "./ide.ts";
|
||||||
|
|
||||||
export type ProcessWorkOrderCallback = (
|
export type ProcessWorkOrderCallback = (
|
||||||
@ -18,6 +20,14 @@ export type ProcessWorkOrderMessage = (
|
|||||||
cb: ProcessWorkOrderCallback,
|
cb: ProcessWorkOrderCallback,
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
|
export type LogMessage = (
|
||||||
|
timestamp: Date,
|
||||||
|
component: GadgetComponent,
|
||||||
|
level: GadgetLogLevel,
|
||||||
|
message: string,
|
||||||
|
metadata?: unknown,
|
||||||
|
) => void;
|
||||||
|
|
||||||
export type StatusMessage = (content: string) => void;
|
export type StatusMessage = (content: string) => void;
|
||||||
|
|
||||||
export type ThinkingMessage = (content: string) => void;
|
export type ThinkingMessage = (content: string) => void;
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
CrashRecoveryResponseMessage,
|
CrashRecoveryResponseMessage,
|
||||||
RequestTerminationMessage,
|
RequestTerminationMessage,
|
||||||
WorkspaceModeChangedMessage,
|
WorkspaceModeChangedMessage,
|
||||||
|
LogMessage,
|
||||||
} from "./drone.ts";
|
} from "./drone.ts";
|
||||||
import {
|
import {
|
||||||
ReleaseSessionLockMessage,
|
ReleaseSessionLockMessage,
|
||||||
@ -55,6 +56,7 @@ export interface ClientToServerEvents {
|
|||||||
* gadget-drone => gadget-code:web
|
* gadget-drone => gadget-code:web
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
log: LogMessage;
|
||||||
status: StatusMessage;
|
status: StatusMessage;
|
||||||
thinking: ThinkingMessage;
|
thinking: ThinkingMessage;
|
||||||
response: ResponseMessage;
|
response: ResponseMessage;
|
||||||
@ -82,6 +84,7 @@ export interface ServerToClientEvents {
|
|||||||
* gadget-code:web => gadget-code:ide
|
* gadget-code:web => gadget-code:ide
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
log: LogMessage;
|
||||||
status: StatusMessage;
|
status: StatusMessage;
|
||||||
thinking: ThinkingMessage;
|
thinking: ThinkingMessage;
|
||||||
response: ResponseMessage;
|
response: ResponseMessage;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user