Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

256
Views
How to colorize parts of log message in winstonJs

I have the below code

const {
    colorize,
    combine,
    json,
    printf,
    simple,
    timestamp,
    errors,
    metadata
} = winston.format;

 private readonly consoleLogger = new winston.transports.Console({
        format: combine(
            errors({ stack: true }),
            metadata(),
            timestamp(),
            colorize({ all: true }),
            simple(),
            printf((info) => {
                const { level, message } = info;

                if (info?.metadata?.stackTrace) {
                    return `[${level}] ${message}\r\n${info.metadata.stackTrace}`;
                }
                return `[${level}] ${message}`;
            })
        )
    });

Based on docs and examples seems colorize will change the color of the whole line. I was wondering how can I colorize different part of string for example in my code I want timestamp, Level and message have different colors like image below

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!