Skip to content

Feature Request: Hide the color character #375

Description

@DeHby

There should be no color symbols in log files

Example:

function createLogger(rootDir: string): Logger<ILogObj> {
  const logger = new Logger<ILogObj>({
    type: "pretty",
    stack: {
      capture: "off",
    },
    pretty: {
      timeZone: "local",
    },
  });

  logger.attachTransport(
    fileTransport({
      path: getLogFile(rootDir),
      append: true,
    })
  );

  return logger;
}

Activity

  1. changed the title [-]Feature Request:[/-] [+]Feature Request: Hide the color character[/+] on Sep 11, 2026
  2. added a commit that references this issue on Sep 11, 2026
  3. terehov commented on Sep 11, 2026

    @terehov
    Contributor

    Thanks for the report! This was a bug: on an interactive terminal, the pretty line passed to transports carried the console's ANSI colors. Fixed in #376 — transport pretty lines are now always plain text, while the console stays colored. It ships with 5.2.0.

    Until then, you can strip the codes yourself:

    import { stripVTControlCharacters } from "node:util";
    
    const file = fileTransport({ path: getLogFile(rootDir), append: true });
    logger.attachTransport({ ...file, write: (record, line) => file.write(record, stripVTControlCharacters(line)) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions