summaryrefslogtreecommitdiff
path: root/includes/watchdog.inc
blob: efc4b461893bf6a37f80ee370f8f07d2423d8eb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?


function watchdog($level, $message) {
  global $user;

  ### Perform query to add new log entry:
  db_query("INSERT INTO watchdog (level, timestamp, user, message, location, hostname) VALUES ($level, '". time() ."', '". addslashes($user->id) ."', '". addslashes($message) ."', '". getenv("SCRIPT_NAME") ."', '". getenv("REMOTE_ADDR") ."')");

  ### Periodically remove old log entries:
  if (time() % 20 == 0) {
    $timestamp = time() - 1209600; // 2 weeks
    db_query("DELETE FROM watchdog WHERE timestamp < $timestamp");
  }
}
 
?>