-
Notifications
You must be signed in to change notification settings - Fork 155
Feature request: widen types for Logger arguments #1777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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. 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); |
That's a fair statement and the above is just a proposal for now.
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. |
Given the lack of traction and that the issue has been open for over a year, I'll close it as not planned. If anyone bumps into this and would like us to revisit parts of it, please open a new issue referencing this one. |
This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so. |
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.
The text was updated successfully, but these errors were encountered: