- Timestamp:
- Aug 5, 2017, 11:21:53 PM (7 years ago)
- Branches:
- master
- Children:
- 253f37f
- Parents:
- 565a43c
- git-author:
- Jason Gross <jgross@mit.edu> (08/05/17 22:06:52)
- git-committer:
- Jason Gross <jasongross9@gmail.com> (08/05/17 23:21:53)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
logging.c
r565a43c r4511ac3 7 7 } owl_log_entry; 8 8 9 typedef struct _owl_log_options { /* noproto */ 10 bool drop_failed_logs; 11 bool display_initial_log_count; 12 } owl_log_options; 9 13 10 14 static GMainContext *log_context; … … 302 306 { 303 307 owl_log_entry *entry; 304 bool drop_failed_logs = *(bool*)data;308 owl_log_options *opts = (owl_log_options *)data; 305 309 int ret; 306 310 int logged_message_count = 0; 307 311 bool all_succeeded = true; 308 312 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)); 313 if (opts->display_initial_log_count) { 314 if (g_queue_is_empty(deferred_entry_queue)) { 315 owl_log_makemsg("There are no logs to flush."); 316 } else { 317 owl_log_makemsg("Attempting to flush %u logs...", 318 g_queue_get_length(deferred_entry_queue)); 319 } 314 320 } 315 321 … … 318 324 logged_message_count++; 319 325 entry = (owl_log_entry*)g_queue_pop_head(deferred_entry_queue); 320 if (! drop_failed_logs) {326 if (!opts->drop_failed_logs) { 321 327 /* Attempt to write the log entry. If it fails, re-queue the entry at 322 328 * the head of the queue. */ … … 334 340 } 335 341 if (logged_message_count > 0) { 336 /* first clear the "attempting to flush" message from the status bar */ 337 owl_log_makemsg(""); 342 if (opts->display_initial_log_count) { 343 /* first clear the "attempting to flush" message from the status bar */ 344 owl_log_makemsg(""); 345 } 338 346 if (!defer_logs) { 339 347 if (all_succeeded) { … … 351 359 } 352 360 353 void owl_log_flush_logs(bool drop_failed_logs) 354 { 355 bool *data = g_new(bool, 1); 356 *data = drop_failed_logs; 361 void owl_log_flush_logs(bool drop_failed_logs, bool quiet) 362 { 363 owl_log_options *data = g_new(owl_log_options, 1); 364 data->drop_failed_logs = drop_failed_logs; 365 data->display_initial_log_count = !quiet; 357 366 358 367 owl_select_post_task(owl_log_write_deferred_entries, … … 641 650 /* flush the deferred logs queue, trying to write the 642 651 * entries to the disk one last time. Drop any failed 643 * entries */ 644 bool bool_true = true; 645 owl_log_write_deferred_entries(&bool_true); 652 * entries, and be quiet about it. */ 653 owl_log_options opts; 654 opts.drop_failed_logs = true; 655 opts.display_initial_log_count = false; 656 owl_log_write_deferred_entries(&opts); 646 657 #if GLIB_CHECK_VERSION(2, 32, 0) 647 658 g_queue_free_full(deferred_entry_queue, owl_log_entry_free);
Note: See TracChangeset
for help on using the changeset viewer.