turbo
turbo copied to clipboard
Do not prefix log output
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
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
This might be a good candidate for another option for log behavior
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) ?
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.
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 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).
I can also pick this up, or help out if necessary.
@gsoltis I tried to do something here. I may miss some modification to improve the PR ^^
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
If it make sense, I still work on my PR to improve it.
I'd definitely appreciate that!
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 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.
FWIW, piping the output into this sed command:
sed -l -E 's/^@[a-zA-Z-]+\/[a-z-]+:[a-z-]+: //'
did the trick for me!
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.
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”.
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.
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 calledno-prefix
- [ ] Add prefix to replayed logs for
full
,hash-only
, andnew-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.
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.
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.
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
Yes please! This is also suppressing eslint/tsc annotations when running in Github actions.
@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.
This is fixed in [email protected]
, you can use --log-prefix=none