Closed greaber closed 9 years ago
Yeah using something like util.inspect
would def provide more info, but that's not really the point of this library. It's not meant to be a full assertion lib. It's a supposed to be small and light - with the benefit of enforcing the message requirement in production.
OK, maybe I should be using something else then. But I don't get really get what the niche for invariant
is supposed to be in this case. If you are going to log an error message at all, why would you want to log one that lacks information? You say invariant
is meant to be small and light, but the download and parsing time and memory usage of something like util.inspect
should be negligible, right?
The log captures primitives perfectly fine. This isn't a logger. Also, for the most part, consumers of this library strip away messages at release time.
Right, I wasn't saying anything about whether messages should or should not be stripped away at release time, just that in any environment where they are not stripped you may as well have good logging of objects as well as primitives. Anyway, I will close the issue since the library is what it is.
I started using this module but noticed that if an object has the default
toString
method and I pass it in a%s
specifier, it gets printed using the default objecttoString
method, which gives the unhelpful string "[object Object]". I would prefer that the printing usedutil.inspect
or something. How do users of invariant typically deal with this issue?