spin icon indicating copy to clipboard operation
spin copied to clipboard

prefix log lines with spin and component-id

Open michelleN opened this issue 2 years ago • 6 comments

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.

michelleN avatar Feb 07 '23 00:02 michelleN

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.

itowlson avatar Feb 07 '23 00:02 itowlson

FWIW Spin logs appear like this, at least on Linux:

image

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!

itowlson avatar Feb 07 '23 00:02 itowlson

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.

michelleN avatar Feb 07 '23 01:02 michelleN

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.

itowlson avatar Feb 07 '23 01:02 itowlson

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.

lann avatar Mar 03 '23 16:03 lann

+1 on additional information on which component a log line originated from.

radu-matei avatar Mar 08 '23 00:03 radu-matei