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

124
Views
javascript: how to avoid starting a new line in backquote?

Inside the backquote, if I start a new line, the printed string will start a new line as well.

e.g.

  winston.format.printf(
    (info) => `${info.timestamp}  ${os.hostname()} ${process.pid} ${info.level}: ${info.message}`,
  ),

will print

2021-Nov-30 01:27:39:2739  MacBook-Pro.local 56939 info: initializeExpress() COMPLETED

But

  winston.format.printf(
    (info) => `${info.timestamp}  ${os.hostname()} 
               ${process.pid} ${info.level}: ${info.message}`,
  ),

will print:

2021-Nov-30 01:27:39:2739  MacBook-Pro.local
    56939 info: initializeExpress() COMPLETED

I had to start a new line in the code because of code specification. But I need to avoid starting a new line in the log message.

How?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

End the template literal at the end of the first line, and concatenate with the next with +.

  winston.format.printf(
    (info) => `${info.timestamp}  ${os.hostname()} ` +
              `${process.pid} ${info.level}: ${info.message}`,
  ),

about 4 years ago · Juan Pablo Isaza Report
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!