-
Notifications
You must be signed in to change notification settings - Fork 14
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(api): /api/clean better logging #280
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -67,6 +67,8 @@ async function cleanupHangQuery( | |||||||||||||||||
throw new Error( | ||||||||||||||||||
`Last cleanup was ${lastCleanup} less than ${QUERY_CLEANUP_MAX_DURATION_SECONDS}s` | ||||||||||||||||||
) | ||||||||||||||||||
} else { | ||||||||||||||||||
console.log('[/api/clean] Starting clean up hang queries') | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
type KillQueryResponse = { | ||||||||||||||||||
|
@@ -97,6 +99,7 @@ async function cleanupHangQuery( | |||||||||||||||||
|
||||||||||||||||||
// Nothing to cleanup | ||||||||||||||||||
if (!killQueryResp || killQueryResp?.rows === 0) { | ||||||||||||||||||
console.log('[/api/clean] Done, nothing to cleanup') | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider using a logging library instead of console.log Using a logging library can provide more control over log levels and output formats, and can be configured to write to different destinations (e.g., files, external logging services). |
||||||||||||||||||
return { | ||||||||||||||||||
lastCleanup, | ||||||||||||||||||
message: 'Nothing to cleanup', | ||||||||||||||||||
|
@@ -108,9 +111,10 @@ async function cleanupHangQuery( | |||||||||||||||||
error instanceof Error && | ||||||||||||||||||
error.message.includes('Unexpected end of JSON input') | ||||||||||||||||||
) { | ||||||||||||||||||
console.log('[/api/clean] Done, nothing to cleanup') | ||||||||||||||||||
return { lastCleanup, message: 'Nothing to cleanup' } | ||||||||||||||||||
} else { | ||||||||||||||||||
console.error(error) | ||||||||||||||||||
console.error('[/api/clean] Error when killing queries:', error) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider using a logging library instead of console.error Using a logging library can provide more control over log levels and output formats, and can be configured to write to different destinations (e.g., files, external logging services).
Suggested change
|
||||||||||||||||||
throw new Error(`Error when killing queries: ${error}`) | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
@@ -126,7 +130,9 @@ async function cleanupHangQuery( | |||||||||||||||||
], | ||||||||||||||||||
format: 'JSONEachRow', | ||||||||||||||||||
}) | ||||||||||||||||||
console.log('[/api/clean] LastCleanup event created') | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider using a logging library instead of console.log Using a logging library can provide more control over log levels and output formats, and can be configured to write to different destinations (e.g., files, external logging services). |
||||||||||||||||||
} catch (error) { | ||||||||||||||||||
console.error("[/api/clean] 'LastCleanup' event creating error:", error) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider using a logging library instead of console.error Using a logging library can provide more control over log levels and output formats, and can be configured to write to different destinations (e.g., files, external logging services). |
||||||||||||||||||
throw new Error(`'LastCleanup' event creating error: ${error}`) | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
|
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.
suggestion: Consider using a logging library instead of console.log
Using a logging library can provide more control over log levels and output formats, and can be configured to write to different destinations (e.g., files, external logging services).