function watchdog

7.x watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $extra_data = "")
6.x watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $extra_data = "")
4.x watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $extra_data = "")
5.x 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.


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.

17 calls to watchdog()
admin_apply_draft_changes_form_submit in modules/admin/admin.module
Handles the actual moving of draft courses into production.
advise_display_view in modules/advise/advise.module
This is the page which actually displays the "view" for the user to see their advising session, or for an advisor to advise them.
blank_degrees_display_blank_degree in modules/blank_degrees/blank_degrees.module
comments_comment_form_submit in modules/comments/comments.module
course_search_display_courses in modules/course_search/course_search.module
Show the user their select of courses.

... See full list


includes/, line 34
This file contains mostly db shortcuts.


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

  // TODO:  Have a setting where, we do not actually log certain severity levels, like notice or debug
  // (to save space)

  $user_id = $user->id;
  $cwid = $user->cwid;
  $user_name = $user->name;
  $is_student = (int) $user->is_student;
  $is_faculty = (int) $user->is_faculty;

  $is_mobile = (int) fp_screen_is_mobile();

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

  $ser_variables = "";
  if (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)
            ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')
            ", $user_id, $user_name, $cwid, $type, $message, $ser_variables, $severity, $extra_data, $location, $referer, $ip, $is_mobule, $is_student, $is_faculty, time());