Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
christianstamati opened this issue Jul 3, 2024 · 0 comments
Open

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

christianstamati opened this issue Jul 3, 2024 · 0 comments

Comments

@christianstamati
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant