How can I write to file without colors and to console with colors?

Open
#698 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, node.js
Domain
tooling

Research direction

No repository file or test is named. Start by reproducing the custom debug.log setup and reviewing the DEBUG_COLORS handling; done means console output retains colors while the file output is plain.

Written by the indexing model from the issue text.

Description

question

I made this function which console logs and writes to file but I'm not able to have the console with colors and the file output without colors

process.env.DEBUG = 'my_app:*'
process.env.DEBUG_COLORS = false
const debug = require('debug')

debug.log = (...args) => {
    console.log(...args)
    const file = 'my_file.txt'
    const line = formatArgs(args)
    fs.appendFileSync(file, line + '\n')
  }
}
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.