yes you heard it right.
we frequently use console.log() to check our outputs in console, it's ok in Development mode but it is highly disgraced in production.
so then what's the solution for it.so in production we basically use production grade loggers.This article is going to teach you how to use ps-logger.
Q.Why ps-logger ?
=>yes you have few other options but the problem is that you have to do lots of manual configurations in it.That's why beginners don't even touch production grade loggers.
ps-logger is a plug and play logger.There is no manual configurations.you have to just install and use it.
npm i ps-logger
- Example:-
const logger=require('ps-logger');
logger.info("This is info")
logger.warn("This is warning");
logger.error("This is error");
logger.debug("This is debug");
logger.prompt("This is prompt");
logger.verbose("This is verbose");
logger.silly("This is silly");
- if you want to disable its colors
logger.setColor(false);
in future updates it will provide more features to you guys
Top comments (23)
But you remove all of the semantic meaning behind the
console.error
,console.warn
etc. as you justconsole.log
everything and add no useful extra information or functionality.So the question is...why???, this is objectively worse than using native console.
All your concerns are addressed and latest update is released. please tell me why are u overhyping console.log, console.log is just a wrapper
I think @inhuofficial is thinking about it in terms of a browser console or tools inside something like Electron. If you were to use your system for client-side code you effectively remove a LOT of the extras provided by the console commands.
Like the ability to filter by type. Where's the link to the filename and line of code the console was called from? You're doing the message, but you're omitting a bunch of very useful features, both client-side and server-side.
Your goofy hard to read colours aren't doing any favors if we don't know what file, function, line, and character offset in the line the report was done from!
Sorry about the "goofy' part. System colours often fail accessibility minimums, and on the whole I'm not a fan of ever-shifting colours. Thus my intense dislike for the illegible acid trip that is colour syntax highlighting. My attitude towards coloured code is basically:
🎵Hate is a strong word, but I really really really don't like you🎵
Jokes aside, without the back-reference or a backtrace or anything else to tell you where the log/warn/error came from, this is as InHu said, somewhat crippled and a step backwards from the native methods.
But what do I know? I have this in several of my codebases because I find console.error to be "incomplete and crippled"
Because if it's an error, that **** should stop dead in its tracks, not blindly plod on like nothing is wrong!
it is the same man, i also don't want use an external library console is better for me
Now its changed,see the latest update
i want the advantages , why are you hiding my comment ???
You will get the advantages just wait for few days 👍
thank you , i want the advantages, why it is different from other libs , so maybe i can help to improve it with some prs
offcourse bro
what is the advantages of using this library, because i can see none ?
This is a good idea 😉
I've programmed it myself so far, but I think you have a better solution than me.
Thanks bro, I just launched it 2 days ago 😀
I made a pull request 😉
Thanks for your contribution , let me check i will surely approve your PR
PR approved 🎉
implement on your own is always the good way to learn something, after checking your repo I found one issue which we got the same date even using a timer, PR raised.
Ok bro let me check 👍
PR APPROVED
Great contribution!!
Thanks
Nice work Shivansh.
Thank you ❤️
If I really need a logger on production, then I would rather log to the file or a log server instead of the console.
I don't know what's the benefit of using a 3rd party console logger.
Some comments have been hidden by the post's author - find out more