dispatchrun / dispatch

Entrypoint of the Dispatch ecosystem.
11 stars 1 forks source link

Prefix logs with source #22

Closed chriso closed 6 months ago

chriso commented 6 months ago

The verbose logs generated in #21 are hard to parse, since the logs from the CLI are interleaved with logs from the local application.

This PR prefixes logs from both sources, and adds color to the prefix, so that it's easy to see where the log line originated from. Colors are enabled when dispatch run is invoked from a terminal and doesn't have its stdout/stderr redirected. Colors can be enabled or disabled using the standard NO_COLOR and FORCE_COLOR environment variables.

Screenshot from 2024-04-19 11-24-01

This is only enabled when using --verbose. Without verbose logging enabled, we continue to print the welcome dialog and then pipe local application logs through to stdout/stderr verbatim.

In a follow up PR, when we enable a TUI for realtime observability, we'll show the verbose logs in a TUI panel.

achille-roussel commented 6 months ago

This is a great addition.

Were there other terms you consider besides "endpoint"? I feel like it might not be the most intuitive for a user what the endpoint is in this context; maybe "command", "program", "process" could better designate the component emitting the logs. Or using the name of the program itself (e.g. "python3").

chriso commented 6 months ago

I chose endpoint because we were using the term elsewhere, and because it has the same number of characters as dispatch.

Updated so that it uses the first argument of the specified command. It trims the path prefix if present. In the example above, it would show uvicorn instead of endpoint.