Skip to content

Driver logging: disable colors when logging to file #78435

@RalfJung

Description

@RalfJung

When debugging a large Miri trace, I like to put the trace into a file that I can analyze and search through in an editor. Unfortunately, since the recent logging changes, that leads to a lot of garbage in the file:

2:rustc│ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m Retag([fn entry] _1)
2:rustc│ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m StorageLive(_2)
2:rustc│ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m StorageLive(_3)
2:rustc│ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m _3 = move _1
2:rustc│ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m Retag(_3)
2:rustc│ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m _2 = std::mem::ManuallyDrop::<std::boxed::Box<T, A>>::new(move _3) -> [return: bb1, unwind: bb5]
2:rustc│ │ │ │ │ │ ├┐�[2mrustc_mir::interpret::eval_context�[0m::�[1;32mframe�[0m std::boxed::Box::<alloc::collections::btree::node::LeafNode<std::string::String, i32>>::into_unique
2:rustc│ │ │ │ │ │ │└┐�[2mrustc_mir::interpret::eval_context�[0m::�[1;32mframe�[0m std::mem::ManuallyDrop::<std::boxed::Box<alloc::collections::btree::node::LeafNode<std::string::String, i32>>>::new
2:rustc│ │ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m // executing bb0
2:rustc│ │ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m Retag([fn entry] _1)
2:rustc│ │ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m StorageLive(_2)
2:rustc│ │ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m _2 = move _1
2:rustc│ │ │ │ │ │ │ ├─�[2m0�[0m�[2mms�[0m �[1;32m INFO�[0m �[2mrustc_mir::interpret::step�[0m Retag(_2)

Looks like the color escape sequences are printed even when redirecting to a file. This makes working with the logfile much harder than it was before. Is there a way to fix that?

Cc @oli-obk

Metadata

Metadata

Assignees

Labels

A-driverArea: rustc_driver that ties everything together into the `rustc` compilerC-enhancementCategory: An issue proposing an enhancement or a PR with one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions