Reputation: 1038
I'm very new to backend web dev and I'm trying to set up a TypeScript project. Most everything else seems fine but when I try to use the Pino
logger, I get this error in the compiled levels.js
file:
throw Error(`default level:${defaultLevel} must be included in custom levels`)
My logger.ts
looks like this:
1 import pino from 'pino';
2
3 const l = pino({
4 name: process.env.APP_ID,
5 level: process.env.LOG_LEVEL,
6 });
7
8 export default l;
The project was bootstrapped via yeoman
.
Not sure if that's enough to debug the issue.
Upvotes: 9
Views: 10540
Reputation: 5084
In my case I set incorrect value for LOG_LEVEL:
LOG_LEVEL=error # error | debug | info
as a result pino.level === 'error # error | debug | info'
So to solve the issue just set up correct values, for my case:
LOG_LEVEL=error
Upvotes: 0
Reputation: 1038
I feel dumb. The issue was that the generator didn't create a .env
; where all those variables should have been defined.
Upvotes: 7