fastify / fastify/help

How can I use custom levers for pino logger with TS?

Open
#862 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
68
Forks
8
Avg merge
11h 2m
Merged PRs (30d)
2

Description

I have legal pino setup levels, but when I try to declare new function for logger fastify is error with regular register method.
```

import { buildApp, startApp, AppOptions, buildEmpty } from './src/app'

const envToLogger = {
development: {
transport: {
target: 'pino-pretty',
options: {
translateTime: 'HH:MM:ss Z',
ignore: 'pid,hostname',
},
},
customLevels: {
init: 35
}
},
production: {
customLevels: {
init: 35
}
},
test: false,
}

const environment = 'development'

const options: AppOptions = {
logger: envToLogger[environment] ?? true,
pluginTimeout: 120_000
}

const start = async () => {
const app = await buildApp(options)
await startApp(app)
}

start()
```

My attempt to extend FastifyBaseLogger which breaks fastify instance methods:
```

declare module 'fastify' {
interface FastifyBaseLogger {
init: any
}
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.