gun icon indicating copy to clipboard operation
gun copied to clipboard

Use `console.warn` and `console.error`

Open atjn opened this issue 2 years ago • 8 comments

A lot of the core Gun code uses console.log for warnings and errors. This PR uses the appropriate console.warn and console.error methods.

This helps with readability in the console, because messages are styled differently depending on their severity. It also helps when using custom debuggers, as you can now filter between log severities.

It is possible that I have used the wrong severity level for a few logs, but I think this is a big step in the right direction, and something that can easily be tweaked when you find those misses :)

atjn avatar Aug 21 '23 08:08 atjn

some of us use custom js environments that don't have .warn ? and is why it has .log as a fallback?

this is the top reason why the pr cant be pulled

bmatusiak avatar Dec 24 '23 17:12 bmatusiak

some of us use custom js environments that don't have .warn ? and is why it has .log as a fallback?

@bmatusiak I was not aware of this, can you point me to some documentation on the environment that doesn't support warn? I have never heard of missing warn functionality. It is part of the original console specification, and it is very easy to just alias log as warn, so I never expected an environment to be missing support.

atjn avatar Dec 29 '23 11:12 atjn

https://www.espruino.com/Reference#console

true,, it could be aliased, but with embedded devices need less code because they only have so much storage

bmatusiak avatar Dec 29 '23 13:12 bmatusiak

This issue should be fixed in the next release of Espruino, see: Issue: https://github.com/espruino/Espruino/issues/1302#issuecomment-1872203845 Commit: https://github.com/espruino/Espruino/commit/08fca8de771b8ae531dba7e8985d6aa73de127a7

Do you have any other custom runtime I should look into?

atjn avatar Jan 02 '24 12:01 atjn

nice!. will re-review when the time comes

bmatusiak avatar Jan 02 '24 16:01 bmatusiak

@bmatusiak This is now released in Espruino 2v20. Docs: https://www.espruino.com/Reference#t_l_console_warn

atjn avatar Jan 10 '24 15:01 atjn

oye, I guess if even espruino supports it... that's :P probably ticks a lot of boxes (I'm like @bmatusiak on these matters too). Tho @bmatusiak doing the labor of love of testing/fixing cross-env support, so if he thumbs up I'll pull.

amark avatar Feb 07 '24 04:02 amark

I just rebased the code. Looking forward to your review @bmatusiak :)

atjn avatar Feb 07 '24 12:02 atjn