Changeset 3d1a2db for logging.c


Ignore:
Timestamp:
Feb 12, 2014, 3:05:21 PM (8 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
ce23cb4
Parents:
4772817
git-author:
Jason Gross <jgross@mit.edu> (01/01/14 11:23:17)
git-committer:
Jason Gross <jgross@mit.edu> (02/12/14 15:05:21)
Message:
Let the user know when the logs have been flushed

I've found it a bit disconcerting to have no feedback on whether or not
:flush-logs has succeeded, and on whether or not we're still in deferred
logging mode.  Perhaps a message (owl_function_makemsg with no newline)
would be better than adminmsg here, but I'm not sure.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    r09a3afc r3d1a2db  
    153153}
    154154
     155static void owl_log_adminmsg_main_thread(gpointer data)
     156{
     157  owl_function_adminmsg("Logging", (const char*)data);
     158}
     159
    155160static void G_GNUC_PRINTF(1, 2) owl_log_error(const char *fmt, ...)
    156161{
     
    163168
    164169  owl_select_post_task(owl_log_error_main_thread,
     170                       data, g_free, g_main_context_default());
     171}
     172
     173static void G_GNUC_PRINTF(1, 2) owl_log_adminmsg(const char *fmt, ...)
     174{
     175  va_list ap;
     176  char *data;
     177
     178  va_start(ap, fmt);
     179  data = g_strdup_vprintf(fmt, ap);
     180  va_end(ap);
     181
     182  owl_select_post_task(owl_log_adminmsg_main_thread,
    165183                       data, g_free, g_main_context_default());
    166184}
     
    254272  bool drop_failed_logs = *(bool *)data;
    255273  int ret;
     274  bool logged_at_least_one_message = false;
     275  bool all_succeeded = true;
    256276
    257277  defer_logs = false;
    258278  while (!g_queue_is_empty(deferred_entry_queue) && !defer_logs) {
     279    logged_at_least_one_message = true;
    259280    entry = (owl_log_entry*)g_queue_pop_head(deferred_entry_queue);
    260281    if (drop_failed_logs) {
     
    263284      ret = owl_log_try_write_entry(entry);
    264285      if (ret != 0) {
     286        all_succeeded = false;
    265287        owl_log_file_error(entry, ret);
    266288      }
    267289    }
    268290    owl_log_entry_free(entry);
     291  }
     292  if (all_succeeded && logged_at_least_one_message) {
     293    owl_log_adminmsg("Logs have been flushed and logging has resumed.");
    269294  }
    270295}
Note: See TracChangeset for help on using the changeset viewer.