-
Book Overview & Buying
-
Table Of Contents
Full-Stack Web Development with TypeScript 5
By :
Logging is an essential technique that helps us to reconstruct what happened on our backend and also know the other important events that happened. It’s very useful when we actually debug our code to understand what went wrong, and it’s helpful in trying to get more context. In our case, we will use the pino logger, which provides useful functionality out of the box and also allows a decent level of configuration.
Let’s first create a general configuration for our logger so that we can use it from other parts of our application.
We will initialize a main logger with a logging level and then export it:
src/loggers.ts
import pino from "pino";
const mainLogger = pino({
level: Bun.env.LOG_LEVEL || "info",
timestamp: pino.stdTimeFunctions.isoTime,
});
export default mainLogger; Here, we instantiate a main logger, where we specify which level of logging...