function mongodb_watchdog_clear_log_submit in MongoDB 6
Same name and namespace in other branches
- 7 mongodb_watchdog/mongodb_watchdog.admin.inc \mongodb_watchdog_clear_log_submit()
Submit callback: clear database with log messages.
1 call to mongodb_watchdog_clear_log_submit()
- MongoDBLogTestCase::tearDown in mongodb_watchdog/
mongodb_watchdog.test - Clear the MongoDB data: simpletest only clears the main SQL database.
1 string reference to 'mongodb_watchdog_clear_log_submit'
- mongodb_watchdog_clear_log_form in mongodb_watchdog/
mongodb_watchdog.admin.inc - Return form for mongodb_watchdog clear button.
File
- mongodb_watchdog/
mongodb_watchdog.admin.inc, line 402 - Settings for mongodb. Moved back to module file.
Code
function mongodb_watchdog_clear_log_submit() {
try {
// Drop the watchdog collection.
$collection = mongodb_collection(variable_get('mongodb_watchdog', 'watchdog'));
$collection->db
->dropCollection($collection
->getName());
// Recreate the indexes.
module_load_include('install', 'mongodb_watchdog');
mongodb_watchdog_ensure_indexes();
// Drop the event collections.
foreach ($collection->db
->listCollections() as $table) {
$parts = explode('.', $table);
if (substr($parts[1], 0, 15) == 'watchdog_event_') {
$collection->db
->dropCollection($table);
}
}
drupal_set_message(t('MongoDB log cleared.'));
} catch (Exception $e) {
drupal_set_message(t('An error occured while clearing the MongoDB log.'), 'error');
}
}