Add logging

This commit is contained in:
Brandon Thomas committed 2022-06-01 15:54:45 -04:00
1 parent 8df2e3c86e
commit 8792b4c8ae
2 files changed
+16 -1

No files matched your search

@@ -305,6 +305,8 @@ async fn main() -> AnyhowResult<()> {
})
.transpose()?;
info!("Using 'MAYBE_MINIMUM_PRIORITY' of {:?}", maybe_minimum_priority);
let inferencer = Inferencer {
download_temp_directory: temp_directory,
mysql_pool,
@@ -389,7 +391,7 @@ async fn main_loop(inferencer: Inferencer) {
};
if jobs.is_empty() {
noop_logger.log_after_awhile();
noop_logger.log_message_after_awhile("No TTS jobs picked up from database!");
std::thread::sleep(Duration::from_millis(inferencer.job_batch_wait_millis));
continue;
@@ -29,4 +29,17 @@ impl NoOpLogger {
self.op_count += 1;
}
pub fn log_message_after_awhile(&mut self, message: &str) {
let now = Utc::now();
let delta = now - self.last_log_time;
if delta > self.logless_duration {
info!("No operations for {:?}. {} operations: {}", delta, self.op_count, message);
self.op_count = 0;
self.last_log_time = now;
}
self.op_count += 1;
}
}