Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda