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

[Bug]: Cant combine colorize and printf using a string method on info.level #216

Open
danilomourelle opened this issue Oct 13, 2022 · 0 comments

Comments

@danilomourelle
Copy link

danilomourelle commented Oct 13, 2022

The problem

Tried to print using Console transpost with a custon format like [LEVEL] - timestamp: message. For that, I used the printf on format co I could use toUpperCase() on info.level, which worked at first. The problem occured when I tried to combine it with colorize what made it stops showing info.level on console

What version of Logform presents the issue?

v2.4.2

What version of Node are you using?

v16.17.0

If this worked in a previous version of Logform, which was it?

No response

Minimum Working Example

const winston = require('winston');

const logger = winston.createLogger({
    format: winston.format.combine(
        // winston.format.colorize(),
        winston.format.printf(info => `${info.level.toUpperCase()} -> ${info.message}`)
    ),
    transports: [
        new winston.transports.Console()
    ],
    level: 'silly'
});

logger.info('hello')
  • This example prints INFO -> hello with no colors
  • If uncomment colorize line it prints -> hello
  • If delete the .toUpperCase() function it prints info -> hello with level in green

Additional information

No response

🔎 Search Terms

colorize, printf, string methods, toUpperCase

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

1 participant