Skip to content

feat: support specify log color#1529

Merged
svenstaro merged 5 commits intosvenstaro:masterfrom
MrCroxx:xx/log-color
Jan 7, 2026
Merged

feat: support specify log color#1529
svenstaro merged 5 commits intosvenstaro:masterfrom
MrCroxx:xx/log-color

Conversation

@MrCroxx
Copy link
Copy Markdown
Contributor

@MrCroxx MrCroxx commented Oct 10, 2025

As title.

Introduce new arg --log-color with possible values: "auto", "always", "never" to specify log output color.

It is useful for:

miniserve -v --log-color always ... | tee log.txt

@svenstaro
Copy link
Copy Markdown
Owner

I still get colors because log entries aren't the only things that is colored. There's also colored for the manual prints. I reckon these should also be affected. You should be able to do this using https://docs.rs/colored/latest/colored/control/static.SHOULD_COLORIZE.html.

@MrCroxx
Copy link
Copy Markdown
Contributor Author

MrCroxx commented Oct 14, 2025

I still get colors because log entries aren't the only things that is colored.

Hi. I'm afraid I don't get it clearly. The code path with auto argument is the same as its current code. Are you also planning to fix this path as well?

@svenstaro
Copy link
Copy Markdown
Owner

Yes, what I'm saying is that users passing in --log-color never will probably expect to receive absolutely no colored output but currently the output that is printed via colored is still colored while the logged lines using log are not. I think users would expect output to be uncolored, no matter the output facility.

@MrCroxx
Copy link
Copy Markdown
Contributor Author

MrCroxx commented Oct 14, 2025

Yes, what I'm saying is that users passing in --log-color never will probably expect to receive absolutely no colored output but currently the output that is printed via colored is still colored while the logged lines using log are not. I think users would expect output to be uncolored, no matter the output facility.

Oh, I see. Let me handle it.

@svenstaro
Copy link
Copy Markdown
Owner

Do you want to pick this up and finish it?

@MrCroxx
Copy link
Copy Markdown
Contributor Author

MrCroxx commented Nov 14, 2025

Do you want to pick this up and finish it?

Sure. Sorry for the late response. The new Github homepage make me forget this PR.

@MrCroxx
Copy link
Copy Markdown
Contributor Author

MrCroxx commented Nov 14, 2025

Done. PTAL

@svenstaro svenstaro merged commit 84a0021 into svenstaro:master Jan 7, 2026
@svenstaro
Copy link
Copy Markdown
Owner

Thanks!

svenstaro added a commit that referenced this pull request Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants