Skip to content

Uses ANSI escape codes in dumb terminal in Sublime Text #2214

Closed
@kornelski

Description

@kornelski

Bug Report

Sublime Text 4 has a "Build" feature which can launch Rust/Cargo programs and redirect their output to its internal log viewer. This log is only in plain text, without any support for ANSI escape codes. It prints escape codes literally, making log output look messy.

fn main() {
    tracing_subscriber::fmt::init();
    tracing::info!("hello");
}

in Sublime's log looks like:

<0x1b>[2m2022-07-09T21:11:30.802562Z<0x1b>[0m <0x1b>[32m INFO<0x1b>[0m <0x1b>[2mtraa<0x1b>[0m<0x1b>[2m:<0x1b>[0m hello

Sublime does not set any env variables. There's no TERM. It has __CFBundleIdentifier env var set to com.sublimetext.4.

It would be nice if tracing_subscriber could detect if the terminal supports color before using ANSI codes, or at least detect that it's Sublime and it doesn't support them.

Version

tracing v0.1.35
tracing-subscriber v0.3.14
ansi_term v0.12.1

Platform

macOS 12.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions