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

Level colors do not show up when using foreman since 1.0.0 #609

Closed
fiznool opened this issue Apr 18, 2015 · 5 comments · Fixed by #751
Closed

Level colors do not show up when using foreman since 1.0.0 #609

fiznool opened this issue Apr 18, 2015 · 5 comments · Fixed by #751

Comments

@fiznool
Copy link
Contributor

fiznool commented Apr 18, 2015

Since upgrading from 0.9 to 1.0, the level colors are no longer displaying correctly when running the node app with foreman.

For the test file index.js

var winston = require('winston');

var logger = new (winston.Logger)({
  transports: [new (winston.transports.Console)({ level: 'debug', colorize: true })]
});

logger.debug('debug message');
logger.info('info message');
logger.warn('warn message');
logger.error('error message');

and the Procfile:

web: node index.js

Using 0.9.0 I get the following:

0 9 0

Whereas 1.0.0 yields no colors when run with foreman:

1 0 0

@fiznool
Copy link
Contributor Author

fiznool commented Apr 18, 2015

Hmm. On further investigation, it looks like this is an issue with colors/safe.

Updating index.js to the following:

'use strict';

var winston = require('winston');
var colors = require('colors/safe');

var transport = new (winston.transports.Console)({ level: 'debug', colorize: true });
var logger = new (winston.Logger)({
  transports: [transport]
});

logger.debug('debug message with ' + colors.magenta('colored output'));
logger.info('info message with ' + colors.magenta('colored output'));
logger.warn('warn message with ' + colors.magenta('colored output'));
logger.error('error message with ' + colors.magenta('colored output'));

Yields the following with 0.9:

0 9 0-colored

I'll open an issue with the colors library instead.

@fiznool fiznool closed this as completed Apr 18, 2015
@fiznool
Copy link
Contributor Author

fiznool commented Apr 18, 2015

Issue moved to colors library: Marak/colors.js#121

@Darkhogg
Copy link

Darkhogg commented Nov 9, 2015

There seems to be a workaround: By setting colors.enabled to true at any time. They seem to detect if colors are supported and initialize colors.enabled with the result, and within the foreman command they end up detecting that color is not supported.

@fiznool
Copy link
Contributor Author

fiznool commented Nov 9, 2015

Thanks @Darkhogg that works a treat!

I opened a PR so hopefully this will get merged in.

@indexzero
Copy link
Member

Fixed in #751. Released in winston@2.1.1

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

Successfully merging a pull request may close this issue.

3 participants