function watchdog

7.x db.inc watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $extra_data = "")
6.x db.inc watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $extra_data = "")
5.x db.inc watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $extra_data = "")

Add a log entry to the watchdog (log) table.

This is adapted from Drupal 6's watchdog system.

Parameters

string $type: Generally, this is the name of the module, or some other short text which can be used to categorize this log entry. Ex: "system" or "routines".

string $message: This is the actual log message itself. It can be any length, and contain replacement patterns (very similar to the t() function.) Ex: "The user @user has logged in."

array $variables: If replacement patterns exist in the $message, this is where they are defined, similar to the t() function. Ex: array("@user" => $user->name) *

int $severity: One of several constant values, denoting the severity level. Available values:

string $extra_data: Any extra bit of text you want to add on. Must be 255 characters or less. Good for adding extra codes and such which can be queried for later more easily.

133 calls to watchdog()
admin.courses.inc in modules/admin/admin.courses.inc
admin.degrees.inc in modules/admin/admin.degrees.inc
admin.groups.inc in modules/admin/admin.groups.inc
admin.module in modules/admin/admin.module
The administrative configurations for FlightPath.
admin_add_degree_form_submit in modules/admin/admin.degrees.inc
Submit handler for the add_degree_form.

... See full list

2 string references to 'watchdog'
schools.module in modules/schools/schools.module
Schools module.
__schools_add_school_id_to_fp5_tables in modules/schools/schools.module

File

includes/db.inc, line 55
This file contains mostly db shortcuts.

Code

function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $extra_data = "") {
  global $user;


  $user_id = 0;
  $cwid = 0;
  $user_name = "";
  $is_student = 0;
  $is_faculty = 0;
  $school_id = 0;
  if (is_object($user)) {
    $user_id = @$user->id;
    $cwid = @$user->cwid;
    $user_name = @$user->name;
    $is_student = (int) @$user->is_student;
    $is_faculty = (int) @$user->is_faculty;
    $school_id = (int) @$user->school_id;
  }

  $is_mobile = 0; //TODO:  not used anymore! //(int) fp_screen_is_mobile();

  $ip = @$_SERVER ["REMOTE_ADDR"];
  $location = @$_SERVER ["REQUEST_URI"];
  $referer = @$_SERVER ['HTTP_REFERER'];

  $ser_variables = "";
  if (is_array($variables) && count($variables) > 0) {
    $ser_variables = serialize($variables);
  }

  db_query("INSERT INTO watchdog 
            (user_id, user_name, cwid, type, message, variables, severity, extra_data, location, referer, ip, is_mobile, is_student, is_faculty, timestamp, school_id)
            VALUES
            (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
            ", $user_id, $user_name, $cwid, $type, $message, $ser_variables, $severity, $extra_data, $location, $referer, $ip, $is_mobile, $is_student, $is_faculty, time(), $school_id);


}