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
chore: Add automatically the filename : line_nu in log messages, and do some cleaning #2416
base: main
Are you sure you want to change the base?
Conversation
…me of an argument to the logger
I'd rather not complicate the logging with even more logic. It can really hurt performance as the logger is called frequently, and regex processing can be heavy. I'll keep this in mind to patch:
|
@danny-avila
As Kent Beck says “Make it work. Make it right. Make it fast”, Developer Efficiency and Maintainability should be handed sonner in the project lifecycle then Performance ... |
One more comment, I wasted a lot of time on the bug I fixed, and I found it really annoying to work with logs and debug the application, add to this that there is no good developer documentation so understanding the root cause of something currently is not simple. So this PR was not a nice idea I added to the code, but a remedy for a pain I had while working with the project code. |
I understand, but for debug logs, it's not quite as important. It is better suited to log the values being passed. In my opinion, since they are more frequent, we should avoid any additional regex if we can. Also, using error stacks for control flow or program logic is generally not recommended due to potential performance implications and the possibility of varying stack trace formats across different Node.js versions. Most "get current line" solutions are just this, a double whammy of this method + regex getting called rather frequently and performance takes a hit.
Great idea, we can utilize __filename and __dirname to this effect, they may need to be passed to the logger, so for debug logs we can at least get 2 of 3 desired effects: filename/path, but not the current line. The error logger already includes stack trace, and we are not creating an error object ourselves, but we can maybe improve this by 1 - formatting it better I'll reopen this PR in case you are willing to try that approach, but if not, feel free to close. |
Cool, let's ensure we're on the same page. I'll restate the points for clarity—please confirm or correct them: Requirements:General:
Debug Logs:
Error Logs:
Questions:
|
Summary
the main change is
api/config/winston.js
Example:
[./api/server/index.js:99] is created automatically and when you click on it in VS Code on this part it will bring you to the line in the code that produced the message
Other less important changes:
logger.debug('sendMessage', { message, opts });
->logger.debug('sendMessage', { HumanMessage, opts });
since the message argument name is part of the logger system and causes this log instance to malfunction.
in other words: Don't call logger.debug with message as one of the parameters
Change Type
Testing
Mainly manual work, and fixing a test that failed.
Test Configuration:
Checklist
Please delete any irrelevant options.