Overriding Console.log
-
Recently on slack I inquired about overriding Console.log to provide enhanced logging functionality, and I was informed that screeps devs have strongly recommended not to enhance the Console object. Can I get someone to confirm this information and provide some details about why the Console object should not be extended. The only thing I planned to do was add a few lines to filter the console output as needed.
-
I've overridden console.log in browsers before and it does work but I did have to fiddle to get it to work properly as for some reason the
this
context doesn't work how you would normally expect. Also you can end up with devtools giving you the wrong file/line numbers.The simplest option would be to make your own global
Log
object and just use that everywhere instead of usingconsole.log
directly. I think this is what most people are doing.
-
@systemparadox Thanks I shall make my own logging object. Simple enough to do.