spin
spin copied to clipboard
prefix log lines with spin and component-id
It's hard to tell which ~log lines~ output comes from Spin vs from the actual application (a component). It'd be nice to prefix ~log lines~ output with this information: [Spin] and [Component-ID]
For example, if we were to the run the example http rust app which has a single component called hello, the ~logs~ looks like this:
Serving http://127.0.0.1:3000
Available Routes:
hello: http://127.0.0.1:3000 (wildcard)
{"host": "127.0.0.1:3000", "connection": "keep-alive", ... "spin-path-info": "/", "spin-full-url": "http://127.0.0.1:3000/", "spin-matched-route": "/...", "spin-base-path": "/", "spin-raw-component-route": "/...", "spin-component-route": ""}
With the component-id and spin prefixes, the ~logs~ output would look like this.
$ spin up
[Spin] Serving http://127.0.0.1:3000
[Spin] Available Routes:
hello: http://127.0.0.1:3000 (wildcard)
[hello] {"host": "127.0.0.1:3000", "connection": "keep-alive", ... "spin-path-info": "/", "spin-full-url": "http://127.0.0.1:3000/", "spin-matched-route": "/...", "spin-base-path": "/", "spin-raw-component-route": "/...", "spin-component-route": ""}
Would appreciate any feedback here.
Apologies for the pedantry but... the specific Spin output lines you quote are not logs - they are written directly as actionable information for the user. They should not receive logging-style decoration and their layout should be preserved (or at least modified only consciously).
Obviously this does not affect the broader issue - it relates purely to the example.
FWIW Spin logs appear like this, at least on Linux:

The top stanza is logs (only errors by default). Then the startup message, and then the application log. I agree for sure that the startup message runs into the application log rather!
the specific Spin output lines you quote are not logs - they are written directly as actionable information for the user.
good point. I updated the description to be more clear.
I'm not in favour of decorating normal user interaction this way. If we're going to decorate stuff, it should be the stuff you only use for diagnostics when something's gone wrong, not the stuff you see as part of normal operation and that is intended to be interacted with.
Related discussion on Discord: https://discord.com/channels/926888690310053918/1081227946976616528/1081234846430535721
I have several components + a "common/utils" crate where I have some functions used in my different components. When there is a failure in one of these functions, I log an error. My problem is that I don't know which component caused the error.
+1 on additional information on which component a log line originated from.