Logging

note

It is highly recommend that you always use light's logger method over console.log

Introduction

Logging is extremely important when it comes to building application as it lets you debug through your logs. Since the logging community in node is fragmented, light allows you to provide the logging function. By default it uses console but can be overridden in the config/logger.js file like so.

config/logger.js
const { createLogger } = require('light');
module.exports = createLogger({
logger() {
return myCustomLogger;
},
});
caution

Defining a custom logger does not work in all serverless environments. Currently it is verified working in Vercel if you use the config provided in the vercel deployment guide.

Everywhere else in your application you can use the logger by importing it from light.