node.js - Strange symbols in log with winston -


initialization:

var winston = require('winston'); var logger = new (winston.logger)({     levels: {         trace: 0,         input: 1,         verbose: 2,         prompt: 3,         debug: 4,         info: 5,         data: 6,         help: 7,         warn: 8,         error: 9     },     colors: {         trace: 'magenta',         input: 'grey',         verbose: 'cyan',         prompt: 'grey',         debug: 'blue',         info: 'green',         data: 'grey',         help: 'cyan',         warn: 'yellow',         error: 'red'     } });  logger.add(winston.transports.console, {     level: 'error',     prettyprint: true,     colorize: true,     silent: false,     timestamp: false,     json: false }); 

for example call logger this:

logger.info("issandbox: " + issandbox); 

in idea see:

info: issandbox: true

but when i've uploaded script ubuntu server, saw in log:

^[[32minfo^[[39m: issandbox: true

how can fix it?

the codes you're seeing color code escapes. useful when logging terminal/console, interpreted terminal change text color. if logs end in file, codes stored as-is, , not useful.

you can check if output if terminal, , enable colorisation when is:

logger.add(winston.transports.console, {     level       : 'error',     prettyprint : true,     colorize    : process.stdout.istty,     silent      : false,     timestamp   : false,     json        : false }); 

more info on istty flag here.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -