Changeset 565a43c


Ignore:
Timestamp:
Aug 5, 2017, 11:21:53 PM (7 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Branches:
master
Children:
4511ac3
Parents:
89e4294
git-author:
Jason Gross <jgross@mit.edu> (08/05/17 21:44:56)
git-committer:
Jason Gross <jasongross9@gmail.com> (08/05/17 23:21:53)
Message:
Print a message about how many logs are flushed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    r89e4294 r565a43c  
    158158}
    159159
     160static void owl_log_makemsg_main_thread(gpointer data)
     161{
     162  owl_function_makemsg((const char*)data);
     163}
     164
    160165static void G_GNUC_PRINTF(1, 2) owl_log_error(const char *fmt, ...)
    161166{
     
    181186
    182187  owl_select_post_task(owl_log_adminmsg_main_thread,
     188                       data, g_free, g_main_context_default());
     189}
     190
     191static void G_GNUC_PRINTF(1, 2) owl_log_makemsg(const char *fmt, ...)
     192{
     193  va_list ap;
     194  char *data;
     195
     196  va_start(ap, fmt);
     197  data = g_strdup_vprintf(fmt, ap);
     198  va_end(ap);
     199
     200  owl_select_post_task(owl_log_makemsg_main_thread,
    183201                       data, g_free, g_main_context_default());
    184202}
     
    289307  bool all_succeeded = true;
    290308
     309  if (g_queue_is_empty(deferred_entry_queue)) {
     310    owl_log_makemsg("There are no logs to flush.");
     311  } else {
     312    owl_log_makemsg("Attempting to flush %u logs...",
     313                     g_queue_get_length(deferred_entry_queue));
     314  }
     315
    291316  defer_logs = false;
    292317  while (!g_queue_is_empty(deferred_entry_queue) && !defer_logs) {
     
    308333    owl_log_entry_free(entry);
    309334  }
    310   if (all_succeeded && logged_message_count > 0 && !defer_logs) {
    311     owl_log_adminmsg("Logs have been flushed and logging has resumed.");
    312   } else if (!all_succeeded && logged_message_count > 0 && !defer_logs) {
    313     owl_log_adminmsg("Logs have been flushed or dropped and logging has resumed.");
    314   } else if (logged_message_count > 0 && defer_logs) {
    315     owl_log_error("Attempted to flush %d logs; %u deferred logs remain.",
    316                   logged_message_count, g_queue_get_length(deferred_entry_queue));
     335  if (logged_message_count > 0) {
     336    /* first clear the "attempting to flush" message from the status bar */
     337    owl_log_makemsg("");
     338    if (!defer_logs) {
     339      if (all_succeeded) {
     340        owl_log_adminmsg("Flushed %d logs and resumed logging.",
     341                         logged_message_count);
     342      } else {
     343        owl_log_adminmsg("Flushed or dropped %d logs and resumed logging.",
     344                         logged_message_count);
     345      }
     346    } else {
     347      owl_log_error("Attempted to flush %d logs; %u deferred logs remain.",
     348                    logged_message_count, g_queue_get_length(deferred_entry_queue));
     349    }
    317350  }
    318351}
Note: See TracChangeset for help on using the changeset viewer.