Index: modules/dblog/dblog.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/dblog/dblog.admin.inc,v
retrieving revision 1.8
diff -u -p -r1.8 dblog.admin.inc
--- modules/dblog/dblog.admin.inc	19 Jul 2008 07:44:45 -0000	1.8
+++ modules/dblog/dblog.admin.inc	20 Dec 2008 16:37:26 -0000
@@ -21,10 +21,31 @@ function dblog_admin_settings() {
     '#description' => t('The maximum number of rows to keep in the database log. Older entries will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status')))
   );
 
+  $form['dblog_clear'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Clear database log'),
+    '#description' => t('This will permanently remove the log entries from the database.'),
+    '#weight' => '1',
+  );
+
+  $form['dblog_clear']['clear'] = array(
+    '#type' => 'submit',
+    '#value' => t('Clear database logs'),
+    '#submit' => array('dblog_clear_log_submit'),
+  );
+
   return system_settings_form($form);
 }
 
 /**
+ * Submit callback: clear database log.
+ */
+function dblog_clear_log_submit(&$form_state, $form) {
+  db_query("DELETE FROM {watchdog}");
+  drupal_set_message(t('Database log cleared.'));
+}
+
+/**
  * Menu callback; displays a listing of log messages.
  */
 function dblog_overview() {
Index: modules/dblog/dblog.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/dblog/dblog.test,v
retrieving revision 1.12
diff -u -p -r1.12 dblog.test
--- modules/dblog/dblog.test	11 Dec 2008 20:35:37 -0000	1.12
+++ modules/dblog/dblog.test	20 Dec 2008 16:37:27 -0000
@@ -39,6 +39,9 @@ class DBLogTestCase extends DrupalWebTes
     // Login the regular user.
     $this->drupalLogin($this->any_user);
     $this->verifyReports(403);
+
+    //Test clearing of the dblog table
+    $this->doClearTest();
   }
 
   /**
@@ -354,4 +357,37 @@ class DBLogTestCase extends DrupalWebTes
     }
     return $content;
   }
-}
+
+  /**
+   * Login an admin user, create dblog event, and test clearing dblog functionality through the admin interface.
+   */
+  private function doClearTest() {
+    global $base_root;
+    $log = array(
+      'type'        => 'custom',
+      'message'     => 'Log entry added to test the doClearTest clear down.',
+      'variables'   => array(),
+      'severity'    => WATCHDOG_NOTICE,
+      'link'        => NULL,
+      'user'        => $this->big_user,
+      'request_uri' => $base_root . request_uri(),
+      'referer'     => $_SERVER['HTTP_REFERER'],
+      'ip'          => ip_address(),
+      'timestamp'   => REQUEST_TIME,
+      );
+    // Make sure the watchdog actually has an entry.
+    dblog_watchdog($log);
+    //  Now post to clear the db table
+    $edit = array();
+    // Login the admin user.
+    $this->drupalLogin($this->big_user);
+    $this->drupalPost('admin/settings/logging/dblog', $edit, t('Clear database logs'));
+    // Count rows in watchdog that previously related to the deleted user.
+    $select = db_select('watchdog');
+    $select->addExpression('COUNT(*)');
+    $count_after = $select->execute()->fetchField();
+    $this->assertTrue($count_after == 0, t('DBLog contains %count_after records after a clear, %message', array('%count_after' => $count_after)));
+    // drupalLogout() will put an entry into dblog so if checking for number of rows drupalLogout() must be done later.
+    $this->drupalLogout();
+  }
+}
\ No newline at end of file
