gadget/docs/drone-logger.md
2026-05-08 17:55:23 -04:00

2.0 KiB

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 makes use of GadgetLogTransport 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 for display in LogPanel.

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
  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: