-
Notifications
You must be signed in to change notification settings - Fork 200
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
fix(logger): improve error logging structure #2955
Conversation
- Enhance logging of error properties - Capture name and stack for better debugging (Your error handling was so vague, it could moonlight as a fortune cookie)
|
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
services/workflows-service/src/common/utils/winston-logger/winston-logger.ts (1)
75-80
: Ensure critical error properties take precedenceThe current order of property spreading could allow custom properties to override standard error properties.
Consider this order to ensure standard error properties take precedence:
const errorObj = { + ...errorProperties, message: error.message, name: error.name, stack: error.stack, - ...errorProperties, };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
services/workflows-service/src/common/utils/winston-logger/winston-logger.ts
(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
services/workflows-service/src/common/utils/winston-logger/winston-logger.ts
[error] 69-69: Avoid the use of spread (...
) syntax on accumulators.
Spread syntax should be avoided on accumulators (like those in .reduce
) because it causes a time complexity of O(n^2)
.
Consider methods such as .splice or .push instead.
(lint/performance/noAccumulatingSpread)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Analyze (javascript)
- GitHub Check: test_windows
- GitHub Check: build (windows-latest)
- GitHub Check: test_linux
- GitHub Check: build (ubuntu-latest)
- GitHub Check: lint
🔇 Additional comments (1)
services/workflows-service/src/common/utils/winston-logger/winston-logger.ts (1)
82-82
: Well-structured error logging implementationThe error logging structure clearly separates the error details from additional payload, which will improve debugging capabilities.
services/workflows-service/src/common/utils/winston-logger/winston-logger.ts
Outdated
Show resolved
Hide resolved
- Simplify error property extraction logic - Use forEach instead of reduce for clarity and performance (your error handling is starting to look like a messy breakup with too many exes)
By default, Error objects in JavaScript are not enumerable, so their properties (message, name, stack) are excluded when logged via JSON.stringify. e.g. Even with format.errors({ stack: true }) in Winston, passing an Error object directly Also, found an open winston issue where error stacks get omitted when used with splat() Solution is to manually spread the error object within the logger. |
(Your error handling was so vague, it could moonlight as a fortune cookie)
Summary by CodeRabbit