Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for removing color coding #232

Open
Shooshte opened this issue Apr 3, 2021 · 1 comment
Open

Support for removing color coding #232

Shooshte opened this issue Apr 3, 2021 · 1 comment

Comments

@Shooshte
Copy link

Shooshte commented Apr 3, 2021

When writing log files into a .log file escape characters get added before each line. This bloats the log file considerably, and makes it a bit harder to read.

My logger config:

import logdown from 'logdown';
import fs from 'fs';

const output = fs.createWriteStream('./stdout.log');
const errorOutput = fs.createWriteStream('./stderr.log');
const fileLogger = new console.Console(output, errorOutput);

const logger = logdown('API', {
  logger: fileLogger,
  markdown: false,
  plaintext: true
});

logger.state.isEnabled = true;

export default logger;

Usage example and output:

logger.log(`app started on port: ${PORT}`);
�[37m �[39m  [API] app started on port: 3000

I believe this is due to whitespace and colour coding being added to the passed string (inside the console there is whitespace and the text colour is green).
Can support be for the plaintext to remove the formatting or would this be better suited for a plugin?

@SleepWalker
Copy link
Collaborator

According to the source code plaintext was implemented to add support for logging to files, but for some reason this option disable only part of colors leaving the another part on:

https://github.com/caiogondim/logdown.js/blob/master/src/node.js#L88-L109

I think it was made mistakingly and _getDecoratedPrefix() should drop emojis from output too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants