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

239
Views
pino logger as fastify plugin

I have been created my own options and stream for fastify logger:

const logger = pino(
{
  level: 'info',
  ...ecsFormat,
},
pinoMultiStream.multistream([
  { stream: streamToElastic },
  {
    stream: pretty({
      colorize: true,
      sync: true,
      ignore: 'pid',
    }),
  },
]),)

const fastify = Fastify({logger})

now I want to extract this options as fastify plugin, how can I do this functionality? If that’s impossible what can I do to extract this code?

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

0

You can't encapsulate your code into a Fastify plugin because Fastify's logger has been already created at that time.

In this case, you need to define your own logic to build the fastify server's configuration such as a decorator pattern.

The user experience you will get would be something like:

const decorateLogger = require('my-logger-module')

const applicationConfig = loadAppConfig()

decorateLogger(applicationConfig, options)

const app = Fastify(applicationConfig)
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!