Changeset 77beb3c
- Timestamp:
- Aug 5, 2017, 11:21:53 PM (7 years ago)
- Branches:
- master
- Children:
- e6f21ea
- Parents:
- ec36247
- git-author:
- Jason Gross <jgross@mit.edu> (05/26/13 12:50:13)
- git-committer:
- Jason Gross <jasongross9@gmail.com> (08/05/17 23:21:53)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rec36247 r77beb3c 488 488 "SEE ALSO: aaway, zaway"), 489 489 490 OWLCMD_ VOID("flush-logs", owl_command_flushlogs, OWL_CTX_ANY,490 OWLCMD_ARGS("flush-logs", owl_command_flushlogs, OWL_CTX_ANY, 491 491 "flush the queue of messages waiting to be logged", 492 " ",492 "flush-logs [-f | --force]", 493 493 "If BarnOwl failed to log a file, this command tells\n" 494 494 "BarnOwl to try logging the messages that have since\n" 495 "come in, and to resume logging normally."), 495 "come in, and to resume logging normally.\n" 496 "\n" 497 "Normally, if logging any of these messages fails,\n" 498 "that message is added to the queue of messages waiting\n" 499 "to be logged, and any new messages are deferred until\n" 500 "the next :flush-logs. If the --force flag is passed,\n" 501 "any messages on the queue which cannot successfully be\n" 502 "logged are dropped, and BarnOwl will resume logging\n" 503 "normally."), 496 504 497 505 OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY, … … 1444 1452 } 1445 1453 1446 void owl_command_flushlogs(void) 1447 { 1448 owl_log_flush_logs(); 1454 char *owl_command_flushlogs(int argc, const char *const *argv, const char *buff) 1455 { 1456 if (argc == 1) { 1457 owl_log_flush_logs(false); 1458 } else if (argc == 2) { 1459 if (!strcmp(argv[1], "-f") || !strcmp(argv[1], "--force")) { 1460 owl_log_flush_logs(true); 1461 } else { 1462 owl_function_makemsg("Invalid flag to flush-logs: %s", argv[1]); 1463 } 1464 } else { 1465 owl_function_makemsg("Wrong number of arguments for flush-logs."); 1466 } 1467 return NULL; 1449 1468 } 1450 1469 -
logging.c
rec36247 r77beb3c 211 211 } 212 212 #endif 213 214 static 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 } 213 220 214 221 /* If we are deferring log messages, enqueue this entry for writing. … … 236 243 owl_log_deferred_enqueue_message(msg->message, msg->filename); 237 244 } 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); 241 246 } 242 247 } … … 247 252 { 248 253 owl_log_entry *entry; 254 bool drop_failed_logs = *(bool *)data; 255 int ret; 249 256 250 257 defer_logs = false; 251 258 while (!g_queue_is_empty(deferred_entry_queue) && !defer_logs) { 252 259 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 } 254 268 owl_log_entry_free(entry); 255 269 } 256 270 } 257 271 258 void owl_log_flush_logs(void) 259 { 260 owl_select_post_task(owl_log_write_deferred_entries, NULL, NULL, log_context); 272 void 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); 261 281 } 262 282 … … 539 559 { 540 560 /* 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); 543 565 #if GLIB_CHECK_VERSION(2, 32, 0) 544 566 g_queue_free_full(deferred_entry_queue, owl_log_entry_free);
Note: See TracChangeset
for help on using the changeset viewer.