Different formatting for namespaces on TTY and files

Open
#946 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
tooling

Research direction

No files or tests are identified in the issue. Start by locating the formatting path used when debug.log is overridden and compare it with the stderr path. Done means each instance can choose whether to emit ANSI escape sequences and ISO datetimes independently.

Written by the indexing model from the issue text.

Description

It is possible to redirect the output of some namespaces to files (by assigning a function to debug.log), whilst maintaining others to stderr (by keeping debug.log undefined.)

But all lines are formatted the same way. If stderr is a TTY, they all get colours (using ANSI escape sequences), even in files, and no ISO datetime at the beginning. If stderr is not a TTY (e.g. using 2>&1 | cat) then colours are removed everywhere, even on stderr, and an ISO datetime is prepended to each line.

Is it possible to chose the formatting on a per-instance basis? That is, when I override debug.log, I would like to remove ANSI escape sequences, and add the ISO datetimes.

Dominant language
JavaScript
Stars
11.5k
Forks
992
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from debug-js/debug

All issues in debug-js/debug

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.