You are here

function _spam_log_trace in Spam 6

Same name and namespace in other branches
  1. 5.3 spam.module \_spam_log_trace()

Maintain a "trace id", allowing easy tracing of all spam actions for each page load. Only active if logging is set to verbose or higher.

1 call to _spam_log_trace()
spam_log in ./spam.module
Write to the spam_log database table.

File

./spam.module, line 1898
Spam module, v3 Copyright(c) 2006-2008 Jeremy Andrews <jeremy@tag1consulting.com>. All rights reserved.

Code

function _spam_log_trace($message, $type, $id) {
  global $user;
  static $trid = NULL;
  if (!$trid && variable_get('spam_log_level', SPAM_DEBUG) >= SPAM_VERBOSE) {
    $key = md5(microtime() . $message);
    db_query("INSERT INTO {spam_log} (level, content_type, content_id, uid, function, message, hostname, timestamp) VALUES(%d, '%s', '%s', %d, '%s', '%s', '%s', %d)", SPAM_VERBOSE, $type, $id, $user->uid, '_spam_log_trace', $key, ip_address(), time());
    $trid = db_result(db_query("SELECT lid FROM {spam_log} WHERE message = '%s'", $key));
    if ($trid) {
      db_query("UPDATE {spam_log} SET trid = %d, message = '%s' WHERE lid = %d", $trid, t('--'), $trid);
    }
    else {
      $trid = 1;
      spam_log(SPAM_LOG, '_spam_log_trace', t('Failed to obtain a valid trid.'));
    }
  }
  return $trid;
}