Skip to content
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: use error only notifier logging for frequent jobs [DHIS2-17998] #19949

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: use error only notifier logging for frequent jobs [DHIS2-17998]
  • Loading branch information
jbee committed Feb 17, 2025
commit 709506d64f14f335f7584270f518ad2bef322514
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,25 @@ private static void logError(String message, Exception ex) {

private JobProgress startRecording(@Nonnull JobConfiguration job, @Nonnull Runnable observer) {
SystemSettings settings = settingsProvider.getCurrentSettings();
boolean logInfoOnDebug = isLogInfoOnDebug(job, settings);
NotificationLevel level =
job.getJobType().isUsingNotifications()
!logInfoOnDebug && job.getJobType().isUsingNotifications()
? settings.getNotifierLogLevel()
: NotificationLevel.ERROR;
JobProgress tracker = new NotifierJobProgress(notifier, job, level);
boolean logInfoOnDebug =
job.getSchedulingType() != SchedulingType.ONCE_ASAP
&& job.getLastExecuted() != null
&& Duration.between(job.getLastExecuted().toInstant(), Instant.now()).getSeconds()
< settings.getJobsLogDebugBelowSeconds();
RecordingJobProgress progress =
new RecordingJobProgress(messages, job, tracker, true, observer, logInfoOnDebug, false);
recordingsById.put(job.getUid(), progress);
return progress;
}

private static boolean isLogInfoOnDebug(@Nonnull JobConfiguration job, SystemSettings settings) {
return job.getSchedulingType() != SchedulingType.ONCE_ASAP
&& job.getLastExecuted() != null
&& Duration.between(job.getLastExecuted().toInstant(), Instant.now()).getSeconds()
< settings.getJobsLogDebugBelowSeconds();
}

private void stopRecording(@Nonnull String jobId) {
RecordingJobProgress job = recordingsById.get(jobId);
if (job != null) {
Expand Down
Loading