Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pretty-print should not output color if redirected to a file #2

@rtbo

Description

@rtbo

When pretty-print is redirected to a file, ANSI color codes are written in the text like so:

[2019-06-03T21:29:02.454Z] INFO (30) (@slonik): client is checked out from the pool
�[32mpoolId: �[39m   01DCFKXQJTBGX5FT2X8HEKP5JS
�[32mprocessId: �[39m�[34m9192�[39m
�[32mstats: �[39m
  �[32midleConnectionCount: �[39m �[34m0�[39m
  �[32mtotalConnectionCount: �[39m�[34m1�[39m
  �[32mwaitingRequestCount: �[39m �[34m0�[39m

This is pretty unreadable.
The program should try to detect if the written device supports color. It can be done with system calls like isatty on Posix and GetConsoleScreenBufferInfo on Windows. (don't know how to do it on Node though)
There also should also be a flag to force colors on or off regardless of the detection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions