Open dreamorosi opened 12 months ago
We would like to hear more feedback from customers and understand how you use the logger as well as which limitations you have encountered before moving forward.
I have not encountered a situation where a message is not provided in a log statement.
IMO, logs should tell you something and have enough context for one to understand.
Having logs that simply return null
or true
gives the reader no context.
For cases such as the one below, I can see the usage intent. However, this then leads down a path of determining what is json serializable and where it specifically should go in each log item.
This would mean a prescribed prop would need to be used to determine where such data is to be placed in the log. This would then conflict with the current understanding of the library and any usage of a custom formatter.
// @ts-expect-error - second argument must be an object, otherwise we don't know where to put it on the top level
logger.info('hello', 2);
IMO, logs should tell you something and have enough context for one to understand. Having logs that simply return null or true gives the reader no context.
That's a fair statement and the above is just a proposal for now.
I have not encountered a situation where a message is not provided in a log statement.
In production environments this is definitely the case, but especially with debug logs sometimes I have found myself just wanting to log a value and not necessarily wanting to provide a message.
Use case
The current implementation of our Logger is fairly stringent when it comes to types and objects allowed in the logs when compared with the Python implementation.
For instance, in Python it’s possible to log a wide number of objects:
which produce the following logs:
On TypeScript instead, the current typing allows the first argument to only be a string, and the second a limited amount of types (mainly strings, objects, and errors).
A condensed version of the current types, and its limitation can be found in this TS Playground.
We should aim at expanding the type of arguments of the logger to more closely align with the Python counterpart.
Solution/User Experience
You can find the proposed types in this other TS playground, but essentially after the changes, it should be possible to log all the following:
Alternative solutions
No response
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.