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

161
Views
Stream into file USING destination option in pino-multi-stream

Im using this code to stream into a file. But the created file is empty. Is there something wrong with my code?

const fileStream = pinoms.prettyStream(
    {
        prettyPrint: {
            colorize: true,
            levelFirst: true,
            translateTime: "yyyy-dd-mm, h:MM:ss TT",
        },
    },
    pinoms.destination({
        dest: './my-file', // omit for stdout
        minLength: 4096, // Buffer before writing
        sync: true}) // Asynchronous logging)
)

const streams = [
    {stream: fileStream}
]

const logger = pinoms(pinoms.multistream(streams))

logger.info('HELLO %s!', 'World')

In the documentation it says:


const prettyStream = pinoms.prettyStream(
{
 prettyPrint:
  { colorize: true,
    translateTime: "SYS:standard",
    ignore: "hostname,pid" // add 'time' to remove timestamp
  },
 prettifier: require('pino-pretty') // not required, just an example of setting prettifier
    // as well it is possible to set destination option
}
);

So it should be possible.

PS: I know there is the option to put a writestream with fs into it but I want to get the time formatted.

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

0

I found a practicable solution for me. Scince v 7 pino provides the multistream function by it selve. Now I can do all I wanted to do. Using destination and also make the timestamp pretty.

const streams = [
    {stream: pino.destination('test.log')},
    {stream: pretty({
            colorize: true,
            sync: true,
        })}
]

const logger = pino({level: 'info', timestamp: pino.stdTimeFunctions.isoTime}, pino.multistream(streams))

logger.info('HELLO %s!', 'World')
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!