turbo icon indicating copy to clipboard operation
turbo copied to clipboard

Do not prefix log output

Open jpzwarte opened this issue 2 years ago • 13 comments

What version of Turborepo are you using?

1.1.7-canary.5

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Mac

Describe the Bug

Screenshot 2022-03-18 at 15 37 50

All the task log lines are prefixed with the scope, causing the logs to be hard to read.

Expected Behavior

Please do not prefix every log line.

To Reproduce

turbo run build --scope=foo

jpzwarte avatar Mar 18 '22 14:03 jpzwarte

This might be a good candidate for another option for log behavior

gsoltis avatar Mar 24 '22 17:03 gsoltis

This might be a good candidate for another option for log behavior

What about UI or something like cache hit or cache miss? And should we strip prefix if cache log in full mode but replay logs in content only (the new mode) ?

Kingwl avatar Apr 28 '22 11:04 Kingwl

My main use case for this would be to use it with VS Code problem matchers.

There are a bunch of built-in problem matchers (such as $tsc and $eslint-stylish) that parse compiler/linter output. None of them supports prefixed log lines.

JannesMeyer avatar Jun 01 '22 14:06 JannesMeyer

Hi! I am willing to help you implement this feature :)

I have some difficulties to deep dive in the code base and know where we can remove the prefix. I tried to rough changing this line without any success.

Can you help me by pointing me out where to start? :)

Edit I am not sure why but seems that this line has finally some impact 😅 So I am still digging from here

sprohaszka avatar Jun 01 '22 14:06 sprohaszka

@sprohaszka There's going to be a little bit of complexity to this. The targetUi you've identified is one place. You'll also need to look at the LogStreamer instances just below that, as well as replaying the logs. Currently, the prefix is baked into the logs, which is not the best setup. That will either need to be stripped (easiest to do now), or logs updated to not have the prefix (larger change).

gsoltis avatar Jun 01 '22 16:06 gsoltis

I can also pick this up, or help out if necessary.

rafaeltab avatar Jun 03 '22 20:06 rafaeltab

@gsoltis I tried to do something here. I may miss some modification to improve the PR ^^

sprohaszka avatar Jun 08 '22 15:06 sprohaszka

Just wanted to bump this issue. I'm using a custom pino logger that outputs JSON, and my parser gets tripped up by all the log prefixes

sakekasi avatar Aug 16 '22 00:08 sakekasi

If it make sense, I still work on my PR to improve it.

sprohaszka avatar Aug 16 '22 07:08 sprohaszka

I'd definitely appreciate that!

sakekasi avatar Aug 16 '22 21:08 sakekasi

I'd definitely appreciate that!

I need to know what to improve 🙂 I did some modification last time. I don't know if it is enough 🙂

sprohaszka avatar Aug 17 '22 09:08 sprohaszka

@sprohaszka I believe, though you have changed the code, you need to resolve the requested changes from gsoltis. Normally there is a button somewhere to do this on the requested change.

rafaeltab avatar Aug 17 '22 09:08 rafaeltab

FWIW, piping the output into this sed command:

sed -l -E 's/^@[a-zA-Z-]+\/[a-z-]+:[a-z-]+: //'

did the trick for me!

sakekasi avatar Aug 19 '22 20:08 sakekasi

What about not changing the logs at all? Would that be a possibility? Just forward the original streams to stdout.

Right now, by using turbo to run commands, we lose things like colouring, formatting and hyperlinks.

image

FYI, this is explicitly mentioned on the nx docs as one of its advantages over turbo.

Turborepo only uses piping to capture the terminal output. Piping doesn’t work well for the tasks emitting “interesting” output (cypress, webpack, etc). As a result, the terminal output with Turborepo and without it doesn’t look the same. Nx can use piping, but it also supports other strategies. As a result, Nx is able to capture the output “as is”.

nfantone avatar Dec 05 '22 12:12 nfantone

This was one of the few (only?) things I could not find an analog for in Turborepo when migrating from Lerna (which has --no-prefix). I prefer prefixed output by default for local development, but in GitHub Actions the prefix prevents annotations from working correctly.

jrolfs avatar Jan 08 '23 07:01 jrolfs

I see this still has not been implemented, could I pick this up?

If so are the following requirements for this correct?

  • [ ] Stop adding prefixes to the stored logs.
  • [ ] Add an output-logs flag called no-prefix
  • [ ] Add prefix to replayed logs for full, hash-only, and new-only (I'll make sure to double check this list when implementing)
  • [ ] Only add the prefix when output-logs != no-prefix
  • [ ] Make sure this is also supported in the turbo.json file

An alternative would be to add a separate flag --no-prefix, this would allow the combining of settings such as new-only with no prefix.

rafaeltab avatar Jan 08 '23 17:01 rafaeltab

I can only speak for myself, but at least from my perspective "removing prefixes" wouldn't cut it. I'd like turbo to not modify output at all, preserving original colouring, line length, formatting, meta characters, etc. If really needed (i.e.: to detail currently running process in parallel executions), it could maybe add log lines of its own instead of hi-jacking others?

Apologies if this is what you had in mind already.

nfantone avatar Jan 08 '23 20:01 nfantone

I personally don't know to what extent turbo removes coloring, meta characters, etc. I know coloring can be forced with --color, other than that, I'll have to find it out during implementation.

rafaeltab avatar Jan 08 '23 21:01 rafaeltab

I'm seeing interest for:

  • removing log prefixes
  • wanting stdout

In my estimation, making an output mode for stdout covers both concerns and with one swoop. I think that's the ticket!

@Rafaeltab, your point to being able to use this new output mode along with others is great. What do we think of the new list of options being:

  • full | Displays all turbo output
  • hash-only | Show only the hashes of the tasks
  • new-only | Only show turbo output from cache misses
  • stdout-full | Displays all stdout
  • stdout-new-only | Only show stdout from cache misses
  • none

anthonyshew avatar Jan 11 '23 23:01 anthonyshew

Yes please! This is also suppressing eslint/tsc annotations when running in Github actions.

zomars avatar Feb 20 '23 23:02 zomars

@JannesMeyer @zomars You can use tsc-absolute and the suggested problem matcher setup in its README to get TSC annotations appearing correctly when using turborepo.

Note that because TSC does not provide absolute paths, when running in a turborepo style setup GitHub is unable to resolve the paths, so you'll need to use tsc-absolute anyways, even if the prefixes were removed from turborepo.

domdomegg avatar Mar 17 '23 14:03 domdomegg

This is fixed in [email protected], you can use --log-prefix=none

gsoltis avatar Mar 17 '23 15:03 gsoltis