Changeset 71085f0 for logging.c


Ignore:
Timestamp:
Feb 12, 2014, 3:05:20 PM (8 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
09a3afc
Parents:
66dc2c6
git-author:
Jason Gross <jgross@mit.edu> (05/26/13 12:50:13)
git-committer:
Jason Gross <jgross@mit.edu> (02/12/14 15:05:20)
Message:
Add a -f flag to :flush-logs

This allows us to bypass any troublesome messages in the queue.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    r66dc2c6 r71085f0  
    211211}
    212212#endif
     213
     214static void owl_log_file_error(owl_log_entry *msg, int ret)
     215{
     216  owl_log_error("Unable to open file for logging: %s (file %s)",
     217                g_strerror(ret),
     218                msg->filename);
     219}
    213220
    214221/* If we are deferring log messages, enqueue this entry for writing.
     
    236243      owl_log_deferred_enqueue_message(msg->message, msg->filename);
    237244    } else if (ret != 0) {
    238       owl_log_error("Unable to open file for logging: %s (file %s)",
    239                     g_strerror(ret),
    240                     msg->filename);
     245      owl_log_file_error(msg, ret);
    241246    }
    242247  }
     
    247252{
    248253  owl_log_entry *entry;
     254  bool drop_failed_logs = *(bool *)data;
     255  int ret;
    249256
    250257  defer_logs = false;
    251258  while (!g_queue_is_empty(deferred_entry_queue) && !defer_logs) {
    252259    entry = (owl_log_entry*)g_queue_pop_head(deferred_entry_queue);
    253     owl_log_eventually_write_entry(entry);
     260    if (drop_failed_logs) {
     261      owl_log_eventually_write_entry(entry);
     262    } else {
     263      ret = owl_log_try_write_entry(entry);
     264      if (ret != 0) {
     265        owl_log_file_error(entry, ret);
     266      }
     267    }
    254268    owl_log_entry_free(entry);
    255269  }
    256270}
    257271
    258 void owl_log_flush_logs(void)
    259 {
    260   owl_select_post_task(owl_log_write_deferred_entries, NULL, NULL, log_context);
     272void owl_log_flush_logs(bool drop_failed_logs)
     273{
     274  bool *data = g_new(bool, 1);
     275  *data = drop_failed_logs;
     276
     277  owl_select_post_task(owl_log_write_deferred_entries,
     278                       data,
     279                       g_free,
     280                       log_context);
    261281}
    262282
     
    539559{
    540560  /* flush the deferred logs queue, trying to write the
    541    * entries to the disk one last time */
    542   owl_log_write_deferred_entries(NULL);
     561   * entries to the disk one last time.  Drop any failed
     562   * entries */
     563  bool bool_true = true;
     564  owl_log_write_deferred_entries(&bool_true);
    543565#if GLIB_CHECK_VERSION(2, 32, 0)
    544566  g_queue_free_full(deferred_entry_queue, owl_log_entry_free);
Note: See TracChangeset for help on using the changeset viewer.