How can I write to file without colors and to console with colors?
See original GitHub issueI 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')
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to write stdout to file with colors? - Stack Overflow
Usually the program doing the writing determines whether it's writing to a terminal, and if it's not it won't use colours. So it's...
Read more >How to Write Stdout to a File with Colors | Baeldung on Linux
In this tutorial, we'll cover some tools we can use to write standard output to files while preserving their colors.
Read more >Maintain color from script output for later viewing
It makes sense that the color isn't saved since the resulting file is just plain text, but is there any way I can...
Read more >linux - When reading a file with `less` or `more`, how can I get ...
First produce a colorised sample (e.g. ccze -A </var/log/dpkg. log , ls -1 --color /var/log ) then pipe it to most : ls...
Read more >fatih/color: Color package for Go (golang) - GitHub
// Use handy standard colors color.Set(color.FgYellow) fmt.Println("Existing text will now be in yellow") ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I filter it myself:
output:
ok