jonnyreeves/js-logger

Use js-logger as global variable method like console.log

Opened this issue · 0 comments

Hello!
I am developing an app in Next.js and I started adopting this library because I like the way it handles the LOG_LEVELES.
In my project i just created a file logger.ts and added the js-logger export like so:

import jsLogger from "js-logger";
jsLogger.useDefaults();
const logger = jsLogger;
export default logger;

so in my code I can use it like this:

import logger from "@/lib/logger";
logger.log("Hello!");

This works perfectly but I would like to know if we can use it like console.log wirhout importing it in every file. And since I use it to log stuff on server-side and client side (Browser) It should work on both.

I achieved this on client side but on server-side is not working... Is there a way to achieve this? wrap somehow the js-logger library and use it on server side and client side (browser) without importing logger on each file?

Thanks!