DEV Community

Good Bye console.log,no console.log in 2022

SHIVANSH PATEL on December 31, 2021

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...
Collapse
 
grahamthedev profile image
Info Comment hidden by post author - thread only accessible via permalink
GrahamTheDev

But you remove all of the semantic meaning behind the console.error, console.warn etc. as you just console.log everything and add no useful extra information or functionality.

So the question is...why???, this is objectively worse than using native console.

Collapse
 
imshivanshpatel profile image
Info Comment hidden by post author - thread only accessible via permalink
SHIVANSH PATEL

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

Console.prototype.log = function() {
  this._stdout.write(util.format.apply(this, arguments) + '\n');
};
Enter fullscreen mode Exit fullscreen mode
Collapse
 
deathshadow60 profile image
Info Comment hidden by post author - thread only accessible via permalink
deathshadow60 • Edited

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"

     libError = (routine, message, ...data) => {
            console.log(
                libraryName,
                " - Error reported by ",
                routine, 
                "\r\nbacktrace:"
            );
            console.trace();
            throw new Error(message);
        }; // libError

Because if it's an error, that **** should stop dead in its tracks, not blindly plod on like nothing is wrong!

Collapse
 
ezpzdevelopement profile image
Ez Pz Developement

it is the same man, i also don't want use an external library console is better for me

Collapse
 
imshivanshpatel profile image
SHIVANSH PATEL

Now its changed,see the latest update

Collapse
 
ezpzdevelopement profile image
Ez Pz Developement

i want the advantages , why are you hiding my comment ???

Thread Thread
 
imshivanshpatel profile image
SHIVANSH PATEL

You will get the advantages just wait for few days 👍

Thread Thread
 
ezpzdevelopement profile image
Ez Pz Developement • Edited

thank you , i want the advantages, why it is different from other libs , so maybe i can help to improve it with some prs

Thread Thread
 
imshivanshpatel profile image
SHIVANSH PATEL

offcourse bro

Collapse
 
ezpzdevelopement profile image
Info Comment hidden by post author - thread only accessible via permalink
Ez Pz Developement

what is the advantages of using this library, because i can see none ?

Collapse
 
minecodes profile image
Minecodes

This is a good idea 😉
I've programmed it myself so far, but I think you have a better solution than me.

Collapse
 
imshivanshpatel profile image
SHIVANSH PATEL

Thanks bro, I just launched it 2 days ago 😀

Collapse
 
minecodes profile image
Minecodes

I made a pull request 😉

Thread Thread
 
imshivanshpatel profile image
SHIVANSH PATEL

Thanks for your contribution , let me check i will surely approve your PR

Thread Thread
 
imshivanshpatel profile image
SHIVANSH PATEL

PR approved 🎉

Collapse
 
seven_77 profile image
Seven

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.

Collapse
 
imshivanshpatel profile image
SHIVANSH PATEL

Ok bro let me check 👍

Collapse
 
imshivanshpatel profile image
SHIVANSH PATEL

PR APPROVED

Collapse
 
earthboundmisfit profile image
Muzammil

Great contribution!!

Collapse
 
imshivanshpatel profile image
SHIVANSH PATEL

Thanks

Collapse
 
vivekkodira profile image
Vivek Kodira

Nice work Shivansh.

Collapse
 
imshivanshpatel profile image
SHIVANSH PATEL

Thank you ❤️

Collapse
 
lazypro profile image
ChunTing Wu • Edited

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