You are here

function hosting_task_log in Hosting 7.4

Same name and namespace in other branches
  1. 5 task/hosting_task.module \hosting_task_log()
  2. 6.2 task/hosting_task.module \hosting_task_log()
  3. 7.3 task/hosting_task.module \hosting_task_log()

Insert an entry in the task log.

Parameters

$vid: The vid of the task to add an entry for.

$type: The type of log entry being added.

$message: The message for this log entry.

$error: (optional) The error code associated to this log entry.

$timestamp: (optional) The UNIX timestamp of this log message, this defaults to the current time.

4 calls to hosting_task_log()
hosting_migrate_platform_submit_batch in migrate/hosting_migrate.batch.inc
Batch callback for platform migration submission.
hosting_task_cancel in task/hosting_task.module
Cancel a task before it's started.
hosting_task_retry in task/hosting_task.module
Retry the given task
_hosting_task_log in ./task.hosting.inc
Log a message to the current task's node if possible, the screen otherwise.
2 string references to 'hosting_task_log'
hosting_task_update_6005 in task/hosting_task.install
Implements hook_update_N().
hosting_task_update_6006 in task/hosting_task.install
Implements hook_update_N().

File

task/hosting_task.module, line 530
Web server node type is defined here.

Code

function hosting_task_log($vid, $type, $message, $error = '', $timestamp = NULL) {

  // We keep track of nids we've looked up in this request, for faster lookups.
  static $nids = array();
  $timestamp = $timestamp ? $timestamp : REQUEST_TIME;

  // We need to insert the nid in addition to the vid, so look it up.
  if (!isset($nids[$vid])) {
    $nids[$vid] = (int) db_query('SELECT nid FROM {hosting_task} WHERE vid = :vid', array(
      ':vid' => $vid,
    ))
      ->fetchField();
  }
  $id = db_insert('hosting_task_log')
    ->fields(array(
    'vid' => $vid,
    'nid' => $nids[$vid],
    'type' => $type,
    'message' => $message,
    'error' => isset($error) ? $error : '',
    'timestamp' => $timestamp,
  ))
    ->execute();
}