spheredev / neosphere

A lightweight game engine and development platform using JavaScript for game coding, based on the original Sphere engine by Chad Austin but with a redesigned, modern API and brand-new command-line development tools.
http://www.spheredev.org/
Other
105 stars 15 forks source link

Improve logging of objects with SSj.log #270

Open fatcerberus opened 6 years ago

fatcerberus commented 6 years ago

In miniSphere versions up to 5.2.x, passing an object to SSj.log() will cause the engine to JSON.stringify it and print the output. This works well enough for simple data objects (POJOs) but suffers from the usual limitations of JSON serialization, namely that many types of values such as undefined, symbols, functions, etc., are completely unrepresentable in JSON and will therefore be excluded or distorted in the output.

See: https://github.com/fatcerberus/minisphere/issues/269#issuecomment-407122789

This is a suggestion to improve handling of objects in SSj.log such that all properties of an object, both symbol and string keys, are represented as accurately as possible. In practice this will mean walking the object manually instead of sending it to JSON.stringify, so it's not a trivial change.

Tentatively scheduling this for miniSphere 5.3.

fatcerberus commented 5 years ago

Pushed back to 6.0.0. This is not trivial and miniSphere 5.3 is already becoming a huge upgrade so I'd like to start stabilizing it to get ready for release.