feat: Retain colors across process boundary
matthew-carroll opened this issue · comments
Description
I have Dart code that generates static sites, which uses mason_logger for terminal output. The expected terminal color behavior works when calling this code directly from the terminal.
I aslo have a CLI tool, which can be used to run the static generator in a separate process. However, when I do that, I seem to lose all the logger colors. I run that process as follows:
final process = await Process.start(
'dart',
[executableFile.path, ...appArguments],
);
stdout.addStream(process.stdout);
stderr.addStream(process.stderr);
I'd like to retain logger colors in the separate process, too.
I don't know the full scope of this ask, but for reference, I typically run the CLI tool from Android Studio via the built-in terminal.
Hi @matthew-carroll 👋
Thanks for opening an issue!
I believe this is just how Process.start
works. One thing you could do is set the mode to ProcessStartMode.inheritStdio
instead which will preserve the colors:
final process = await Process.start(
'dart',
[executableFile.path, ...appArguments],
mode: ProcessStartMode.inheritStdio,
);
await process.exitCode;
I'm not sure there's anything else mason_logger
can do since this is handled entirely by the dart sdk 🤷
Let me know if that helps 👍
That configuration did it. Thanks!